Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v.17] Fix missing not saved warning #400

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

3.2.3 (Unreleased)
--------------------
- Fix #400: Fixed missing `not saved` warning
- Enh #411: Standardization of Modal Button Positions

3.2.2 (July 9, 2024)
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"version": "3.2.3",
"humhub": {
"minVersion": "1.16"
"minVersion": "1.17"
},
"homepage": "https://github.com/humhub/mail",
"authors": [
Expand Down
13 changes: 13 additions & 0 deletions resources/js/humhub.mail.ConversationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ humhub.module('mail.ConversationView', function (module, require, $) {
});
};

ConversationView.prototype.onbeforeunloadCheck = function () {
var replyRichtext = this.getReplyRichtext();
if (replyRichtext && $(replyRichtext.$[0]).closest('form').find('textarea').val().trim().length) {
return client.confirmUnload();
}

return true;
};

ConversationView.prototype.loader = function (load) {
if (load !== false) {
loader.set(this.$);
Expand Down Expand Up @@ -172,6 +181,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};

ConversationView.prototype.loadMessage = function (evt) {
if (!this.onbeforeunloadCheck()) {
return false;
}

var messageId = object.isNumber(evt) ? evt : evt.$trigger.data('message-id');
var that = this;
this.loader();
Expand Down
19 changes: 16 additions & 3 deletions resources/js/humhub.mail.messenger.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ humhub.module('mail.ConversationView', function (module, require, $) {
});
};

ConversationView.prototype.onbeforeunloadCheck = function () {
var replyRichtext = this.getReplyRichtext();
if (replyRichtext && $(replyRichtext.$[0]).closest('form').find('textarea').val().trim().length) {
return client.confirmUnload();
}

return true;
};

ConversationView.prototype.loader = function (load) {
if (load !== false) {
loader.set(this.$);
Expand Down Expand Up @@ -172,6 +181,10 @@ humhub.module('mail.ConversationView', function (module, require, $) {
};

ConversationView.prototype.loadMessage = function (evt) {
if (!this.onbeforeunloadCheck()) {
return false;
}

var messageId = object.isNumber(evt) ? evt : evt.$trigger.data('message-id');
var that = this;
this.loader();
Expand Down Expand Up @@ -415,7 +428,7 @@ humhub.module('mail.ConversationView', function (module, require, $) {

module.export = ConversationView;
});

humhub.module('mail.ConversationEntry', function (module, require, $) {

var Widget = require('ui.widget').Widget;
Expand All @@ -439,7 +452,7 @@ humhub.module('mail.ConversationEntry', function (module, require, $) {
};

module.export = ConversationEntry;
});
});
humhub.module('mail.inbox', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var Filter = require('ui.filter').Filter;
Expand Down Expand Up @@ -703,7 +716,7 @@ humhub.module('mail.inbox', function (module, require, $) {
toggleInbox: toggleInbox
});
});

humhub.module('mail.conversation', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var modal = require('ui.modal');
Expand Down
2 changes: 1 addition & 1 deletion resources/js/humhub.mail.messenger.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/js/humhub.mail.notification.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions widgets/ConversationView.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace humhub\modules\mail\widgets;

use Yii;
use humhub\widgets\JsWidget;
use humhub\modules\mail\helpers\Url;

Expand Down
Loading