Skip to content

Commit a26b043

Browse files
committed
Do not allow delete non empty pages/panels and copy them
1 parent aea9a25 commit a26b043

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

wwwroot/js/creatorjs.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ function setupCreatorForContentManager(creator) {
3636
// Hide the "Add Question" button from the design surface
3737
creator.showAddQuestionButton = false;
3838
creator.onElementAllowOperations.add((_, options) => {
39-
if (!options.obj.isQuestion) return;
40-
// Disallow content managers to change question types, delete questions, or copy them
39+
// Disallow restricted users to change question types, delete questions, or copy them
4140
options.allowChangeType = false;
4241
options.allowCopy = false;
43-
options.allowDelete = false;
42+
const obj = options.obj;
43+
if (obj.isQuestion) {
44+
options.allowDelete = false;
45+
}
46+
if (obj.isPage || obj.isPanel) {
47+
options.allowDelete = obj.questions.length === 0;
48+
}
4449
});
4550
creator.onCollectionItemAllowOperations.add((_, options) => {
4651
// Disallow content managers to delete columns via adorners on the design surface

0 commit comments

Comments
 (0)