Skip to content

Commit

Permalink
Merge pull request #992 from ONLYOFFICE/bugfiz/watermark
Browse files Browse the repository at this point in the history
Bugfiz/watermark
  • Loading branch information
LinneyS authored May 23, 2024
2 parents 02cce30 + 18746fb commit 32b0a8f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

##
## Changed
- fix settings page when tag app is disabled

## 9.2.0
## Changed
- compatible with Nextcloud 29
Expand Down
112 changes: 62 additions & 50 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,62 +83,75 @@
$("#onlyofficeWatermark_link_sensitive").toggleClass("onlyoffice-hide");
});

var watermarkLists = [
"allGroups",
var watermarkGroupLists = [
"allGroups"
];

var watermarkTagLists = [
"allTags",
"linkTags",
];
OC.SystemTags.collection.fetch({
success: function () {
$.each(watermarkLists, function (i, watermarkList) {
var watermarkListToggle = function () {
if ($("#onlyofficeWatermark_" + watermarkList).prop("checked")) {
if (watermarkList.indexOf("Group") >= 0) {
OC.Settings.setupGroupsSelect($("#onlyofficeWatermark_" + watermarkList + "List"));
} else {
$("#onlyofficeWatermark_" + watermarkList + "List").select2({
allowClear: true,
closeOnSelect: false,
multiple: true,
separator: "|",
toggleSelect: true,
placeholder: t(OCA.Onlyoffice.AppName, "Select tag"),
query: _.debounce(function (query) {
query.callback({
results: OC.SystemTags.collection.filterByName(query.term)
});
}, 100, true),
initSelection: function (element, callback) {
var selection = ($(element).val() || []).split("|").map(function (tagId) {
return OC.SystemTags.collection.get(tagId);
});
callback(selection);
},
formatResult: function (tag) {
return OC.SystemTags.getDescriptiveTag(tag);
},
formatSelection: function (tag) {
return tag.get("name");
},
sortResults: function (results) {
results.sort(function (a, b) {
return OC.Util.naturalSortCompare(a.get("name"), b.get("name"));
});
return results;
}

var watermarkNodeBehaviour = function (watermark){
var watermarkListToggle = function () {
if ($("#onlyofficeWatermark_" + watermark).prop("checked")) {
if (watermark.indexOf("Group") >= 0) {
OC.Settings.setupGroupsSelect($("#onlyofficeWatermark_" + watermark + "List"));
} else {
$("#onlyofficeWatermark_" + watermark + "List").select2({
allowClear: true,
closeOnSelect: false,
multiple: true,
separator: "|",
toggleSelect: true,
placeholder: t(OCA.Onlyoffice.AppName, "Select tag"),
query: _.debounce(function (query) {
query.callback({
results: OC.SystemTags.collection.filterByName(query.term)
});
}, 100, true),
initSelection: function (element, callback) {
var selection = ($(element).val() || []).split("|").map(function (tagId) {
return OC.SystemTags.collection.get(tagId);
});
callback(selection);
},
formatResult: function (tag) {
return OC.SystemTags.getDescriptiveTag(tag);
},
formatSelection: function (tag) {
return tag.get("name");
},
sortResults: function (results) {
results.sort(function (a, b) {
return OC.Util.naturalSortCompare(a.get("name"), b.get("name"));
});
return results;
}
} else {
$("#onlyofficeWatermark_" + watermarkList + "List").select2("destroy");
}
};
});
}
} else {
$("#onlyofficeWatermark_" + watermark + "List").select2("destroy");
}
};

$("#onlyofficeWatermark_" + watermarkList).click(watermarkListToggle);
watermarkListToggle();
});
}
$("#onlyofficeWatermark_" + watermark).click(watermarkListToggle);
watermarkListToggle();
};

$.each(watermarkGroupLists, function (i, watermarkGroup) {
watermarkNodeBehaviour(watermarkGroup);
});

if (OC.SystemTags && OC.SystemTags.collection) {
OC.SystemTags.collection.fetch({
success: function () {
$.each(watermarkTagLists, function (i, watermarkTag) {
watermarkNodeBehaviour(watermarkTag);
});
}
});
}

$("#onlyofficeAddrSave").click(function () {
$(".section-onlyoffice").addClass("icon-loading");
Expand Down Expand Up @@ -280,11 +293,10 @@
watermarkSettings[watermarkLabel] = $("#onlyofficeWatermark_" + watermarkLabel).is(":checked");
});

$.each(watermarkLists, function (i, watermarkList) {
$.each(watermarkGroupLists.concat(watermarkTagLists), function (i, watermarkList) {
var list = $("#onlyofficeWatermark_" + watermarkList).is(":checked") ? $("#onlyofficeWatermark_" + watermarkList + "List").val() : "";
watermarkSettings[watermarkList + "List"] = list ? list.split("|") : [];
});

}

$.ajax({
Expand Down

0 comments on commit 32b0a8f

Please sign in to comment.