2021-02-19 10:44:56 +00:00
|
|
|
/* global dojo, Plugins, xhr, App, Notify, fox, __ */
|
2021-02-12 12:22:10 +00:00
|
|
|
|
2020-02-27 04:59:57 +00:00
|
|
|
Plugins.Note = {
|
|
|
|
edit: function(id) {
|
2021-02-12 12:22:10 +00:00
|
|
|
const dialog = new fox.SingleUseDialog({
|
2020-02-27 04:59:57 +00:00
|
|
|
title: __("Edit article note"),
|
|
|
|
execute: function () {
|
|
|
|
if (this.validate()) {
|
|
|
|
Notify.progress("Saving article note...", true);
|
|
|
|
|
2021-02-19 07:22:00 +00:00
|
|
|
xhr.json("backend.php", this.attr('value'), (reply) => {
|
2020-02-27 04:59:57 +00:00
|
|
|
Notify.close();
|
|
|
|
dialog.hide();
|
|
|
|
|
|
|
|
if (reply) {
|
2021-02-19 14:15:22 +00:00
|
|
|
App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => {
|
|
|
|
elem.querySelector(".body").innerHTML = reply.note;
|
2020-02-27 04:59:57 +00:00
|
|
|
|
2021-02-19 14:15:22 +00:00
|
|
|
if (reply.note)
|
|
|
|
elem.show();
|
2020-02-27 04:59:57 +00:00
|
|
|
else
|
2021-02-19 14:15:22 +00:00
|
|
|
elem.hide();
|
|
|
|
});
|
2020-02-27 04:59:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-02-17 11:56:36 +00:00
|
|
|
content: __("Loading, please wait...")
|
|
|
|
});
|
|
|
|
|
|
|
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
|
|
|
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php", App.getPhArgs("note", "edit", {id: id}), (reply) => {
|
|
|
|
dialog.attr('content', reply);
|
2021-02-17 11:56:36 +00:00
|
|
|
});
|
2011-12-21 06:58:06 +00:00
|
|
|
});
|
2020-02-27 04:59:57 +00:00
|
|
|
|
|
|
|
dialog.show();
|
2011-12-21 06:58:06 +00:00
|
|
|
}
|
2021-02-12 12:22:10 +00:00
|
|
|
};
|