0 Votes

Changes for page LiveTable View Sheet

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

From version 2.1
edited by Сергей Коршунов
on 2022/03/08 16:59
Change comment: Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.1]
To 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]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.skorshunov
1 +XWiki.admins
XWiki.JavaScriptExtension[0]
Code
... ... @@ -69,7 +69,7 @@
69 69   }
70 70   // Hijack the rename page action.
71 71   var renameAppModal = $('#renameAppModal');
72 - $('#tmActionRename').on('click', function(event) {
72 + $('#tmActionRename').click(function(event) {
73 73   event.preventDefault();
74 74   renameAppModal.modal();
75 75   });
... ... @@ -109,15 +109,18 @@
109 109   $.ajax({
110 110   type: 'HEAD',
111 111   url: newAppHomePage.getURL()
112 - }).then(endValidation.bind(null, pageExistsError), response => {
112 + }).done(function() {
113 + endValidation(pageExistsError);
114 + }).fail(function(response) {
113 113   if (response.status === 404) {
114 114   $.ajax({
115 115   type: 'HEAD',
116 116   url: newAppHomePage.getURL('edit')
117 - }).then(
118 - () => endValidation(),
119 - () => endValidation(locationForbiddenError)
120 - );
119 + }).done(function() {
120 + endValidation();
121 + }).fail(function() {
122 + endValidation(locationForbiddenError);
123 + });
121 121   } else if (response.status === 403) {
122 122   endValidation(locationForbiddenError);
123 123   } else {
... ... @@ -164,7 +164,7 @@
164 164   renameAppModal.modal('show');
165 165   });
166 166  
167 - renameAppModal.find('form').on('submit', function(event) {
170 + renameAppModal.find('form').submit(function(event) {
168 168   event.preventDefault();
169 169   renameApp(getRenameData($(this)));
170 170   });
... ... @@ -197,7 +197,7 @@
197 197   'inprogress'
198 198   );
199 199   var renameAppURL = new XWiki.Document('RenameApplication', 'AppWithinMinutes').getURL('get');
200 - $.post(renameAppURL, data).then(updateAppHomePage).then(function() {
203 + $.post(renameAppURL, data).then(updateAppHomePage).done(function() {
201 201   renameAppModal.modal('hide');
202 202   notification.replace(new XWiki.widgets.Notification(
203 203   $jsontool.serialize($services.localization.render('appWithinMinutes.renameApp.done')),
... ... @@ -207,12 +207,12 @@
207 207   setTimeout(function() {
208 208   window.location.href = getNewAppHomePage().getURL();
209 209   }, 0);
210 - }).catch(function() {
213 + }).fail(function() {
211 211   notification.replace(new XWiki.widgets.Notification(
212 212   $jsontool.serialize($services.localization.render('appWithinMinutes.renameApp.failed')),
213 213   'error'
214 214   ));
215 - }).finally(function() {
218 + }).always(function() {
216 216   // Re-enable the form.
217 217   renameAppModal.find(':input').prop('disabled', false);
218 218   });
... ... @@ -219,17 +219,21 @@
219 219   };
220 220  
221 221   var updateAppHomePage = function() {
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 - });
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 + }
233 233   });
240 + return deferred.promise();
234 234   }
235 235  });