0 Votes

Changes for page LiveTable View Sheet

Last modified by Сергей Коршунов on 2025/05/01 21:19

From version 1.1
edited by admins admins
on 2021/12/11 17:11
Change comment: Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/13.10]
To version 2.1
edited by Сергей Коршунов
on 2022/03/08 16:59
Change comment: Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.1]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.admins
1 +XWiki.skorshunov
XWiki.JavaScriptExtension[0]
Code
... ... @@ -69,7 +69,7 @@
69 69   }
70 70   // Hijack the rename page action.
71 71   var renameAppModal = $('#renameAppModal');
72 - $('#tmActionRename').click(function(event) {
72 + $('#tmActionRename').on('click', function(event) {
73 73   event.preventDefault();
74 74   renameAppModal.modal();
75 75   });
... ... @@ -109,18 +109,15 @@
109 109   $.ajax({
110 110   type: 'HEAD',
111 111   url: newAppHomePage.getURL()
112 - }).done(function() {
113 - endValidation(pageExistsError);
114 - }).fail(function(response) {
112 + }).then(endValidation.bind(null, pageExistsError), response => {
115 115   if (response.status === 404) {
116 116   $.ajax({
117 117   type: 'HEAD',
118 118   url: newAppHomePage.getURL('edit')
119 - }).done(function() {
120 - endValidation();
121 - }).fail(function() {
122 - endValidation(locationForbiddenError);
123 - });
117 + }).then(
118 + () => endValidation(),
119 + () => endValidation(locationForbiddenError)
120 + );
124 124   } else if (response.status === 403) {
125 125   endValidation(locationForbiddenError);
126 126   } else {
... ... @@ -167,7 +167,7 @@
167 167   renameAppModal.modal('show');
168 168   });
169 169  
170 - renameAppModal.find('form').submit(function(event) {
167 + renameAppModal.find('form').on('submit', function(event) {
171 171   event.preventDefault();
172 172   renameApp(getRenameData($(this)));
173 173   });
... ... @@ -200,7 +200,7 @@
200 200   'inprogress'
201 201   );
202 202   var renameAppURL = new XWiki.Document('RenameApplication', 'AppWithinMinutes').getURL('get');
203 - $.post(renameAppURL, data).then(updateAppHomePage).done(function() {
200 + $.post(renameAppURL, data).then(updateAppHomePage).then(function() {
204 204   renameAppModal.modal('hide');
205 205   notification.replace(new XWiki.widgets.Notification(
206 206   $jsontool.serialize($services.localization.render('appWithinMinutes.renameApp.done')),
... ... @@ -210,12 +210,12 @@
210 210   setTimeout(function() {
211 211   window.location.href = getNewAppHomePage().getURL();
212 212   }, 0);
213 - }).fail(function() {
210 + }).catch(function() {
214 214   notification.replace(new XWiki.widgets.Notification(
215 215   $jsontool.serialize($services.localization.render('appWithinMinutes.renameApp.failed')),
216 216   'error'
217 217   ));
218 - }).always(function() {
215 + }).finally(function() {
219 219   // Re-enable the form.
220 220   renameAppModal.find(':input').prop('disabled', false);
221 221   });
... ... @@ -222,21 +222,17 @@
222 222   };
223 223  
224 224   var updateAppHomePage = function() {
225 - var deferred = $.Deferred();
226 - var newAppHomePageEditURL = getNewAppHomePage().getURL('edit');
227 - $('<div/>').load(newAppHomePageEditURL + ' #inline', function() {
228 - var formData = $(this).children('form#inline').serializeArray();
229 - if (formData.length > 0) {
230 - formData.push({name: 'xaction_save', value: true});
231 - $.post(newAppHomePageEditURL, formData).done(function() {
232 - deferred.resolve();
233 - }).fail(function() {
234 - deferred.reject();
235 - });
236 - } else {
237 - deferred.reject();
238 - }
222 + return new Promise((resolve, reject) => {
223 + var newAppHomePageEditURL = getNewAppHomePage().getURL('edit');
224 + $('<div/>').load(newAppHomePageEditURL + ' #inline', function() {
225 + var formData = $(this).children('form#inline').serializeArray();
226 + if (formData.length) {
227 + formData.push({name: 'xaction_save', value: true});
228 + $.post(newAppHomePageEditURL, formData).then(resolve, reject);
229 + } else {
230 + reject();
231 + }
232 + });
239 239   });
240 - return deferred.promise();
241 241   }
242 242  });