Modifications pour le document LiveTableEditSheet

Modifié par Florent Charton le 2024/08/08 18:40

Depuis la version 1.1
modifié par superadmin
sur 2022/06/20 08:43
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/13.10.6]
À la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:40
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/15.10.11]

Résumé

Détails

Propriétés de la Page
Auteur du document
... ... @@ -1,1 +1,1 @@
1 -XWiki.superadmin
1 +XWiki.fcharton
Contenu
... ... @@ -4,7 +4,7 @@
4 4  
5 5  {{velocity output="false"}}
6 6  #macro (listAvailableColumns $classReference)
7 - <select id="availableColumns">
7 + <select id="availableColumns" aria-describedby='availableColumnsHint'>
8 8   #set ($classFields = $xwiki.getDocument($classReference).getxWikiClass().properties)
9 9   #if ($classFields.size() > 0)
10 10   <optgroup label="$escapetool.xml($services.localization.render(
... ... @@ -112,8 +112,8 @@
112 112   </dt>
113 113   <dd>#displayPropertyValue('description')</dd>
114 114   <dt>
115 - <label for="AppWithinMinutes.LiveTableClass_0_columns">$doc.displayPrettyName('columns', false, false)</label>
116 - <span class="xHint">$services.localization.render('platform.appwithinminutes.liveTableEditorColumnsHint')</span>
115 + <label id='availableColumnsLabel' for="AppWithinMinutes.LiveTableClass_0_columns">$doc.displayPrettyName('columns', false, false)</label>
116 + <span id='availableColumnsHint' class="xHint">$services.localization.render('platform.appwithinminutes.liveTableEditorColumnsHint')</span>
117 117   </dt>
118 118   <dd>#displayPropertyValue('columns')</dd>
119 119   </dl>
... ... @@ -170,8 +170,6 @@
170 170   {{html clean="false"}}
171 171   #set ($liveTableObj = $doc.getObject('AppWithinMinutes.LiveTableClass', true))
172 172   #set ($discard = $doc.use($liveTableObj))
173 - #set ($discard = $xwiki.jsfx.use('js/scriptaculous/effects.js'))
174 - #set ($discard = $xwiki.jsfx.use('js/scriptaculous/dragdrop.js'))
175 175   #set ($discard = $xwiki.ssx.use('AppWithinMinutes.LiveTableEditSheet'))
176 176   #set ($discard = $xwiki.jsx.use('AppWithinMinutes.LiveTableEditSheet'))
177 177   #if ("$!request.wizard" == 'true')
... ... @@ -195,7 +195,9 @@
195 195   ## Grant space administration rights only if the space is new. Don't overwrite existing space preferences.
196 196   #set ($spaceHomeRef = $services.model.resolveDocument('', 'default', $spaceRef))
197 197   #set ($spacePrefsRef = $services.model.resolveDocument('WebPreferences', 'explicit', $spaceRef))
198 - #if (!$xwiki.exists($spaceHomeRef) && !$xwiki.exists($spacePrefsRef))
196 + ## Verify that the current user has script right on the current space home.
197 + #set ($hasScript = $services.security.authorization.hasAccess('script', $xcontext.userReference, $spaceHomeRef))
198 + #if ($hasScript && !$xwiki.exists($spaceHomeRef) && !$xwiki.exists($spacePrefsRef))
199 199   #set ($spacePrefsDoc = $xwiki.getDocument($spacePrefsRef))
200 200   #set ($discard = $spacePrefsDoc.use($spacePrefsDoc.getObject('XWiki.XWikiGlobalRights', true)))
201 201   #set ($discard = $spacePrefsDoc.set('allow', 1))
... ... @@ -317,6 +317,10 @@
317 317  {{/velocity}}
318 318  
319 319  {{velocity}}
320 +#if (!$services.security.authorization.hasAccess('script', $xcontext.userReference, $doc.documentReference))
321 + {{error}}{{translation key="platform.appwithinminutes.appHomePageNoScriptRight" /}}{{/error}}
322 +
323 +#end
320 320  #if ("$!request.wizard" == 'true')
321 321   {{include reference="AppWithinMinutes.WizardStep" /}}
322 322  #end
XWiki.JavaScriptExtension[0]
Code
... ... @@ -66,6 +66,7 @@
66 66  
67 67   var picker = new Element('div', {'class': 'columnPicker'}).insert(this.columnsSelect).insert(addButton);
68 68   this.columnsInput.up().insert(picker);
69 + $('availableColumnsLabel').setAttribute('for', 'availableColumns');
69 69   },
70 70   _onAddColumn : function(event) {
71 71   event.stop();
... ... @@ -121,11 +121,7 @@
121 121   }
122 122  });
123 123  
124 -function init() {
125 - var form = $('inline');
126 - if (!form) {
127 - return false;
128 - }
125 +function initForm(form) {
129 129   // Let the sheet handle the form submit. The form is submitted by default to the preview action which dispatches the
130 130   // request to the save action if the save button is detected on the request parameters. By submitting to the edit
131 131   // action the edit sheet is evaluated and thus it can handle the save by itself.
... ... @@ -154,9 +154,18 @@
154 154   }.bindAsEventListener(window));
155 155  
156 156   new XWiki.LiveTableEditor();
154 +}
157 157  
158 - return true;
156 +function init() {
157 + var form = $('inline');
158 + if (form) {
159 + require(['scriptaculous/dragdrop'], function() {
160 + initForm(form);
161 + });
162 + }
163 + return form;
159 159  }
165 +
160 160  (XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init);
161 161  
162 162  // Allow widgets to catch the save event before the form is submitted when the 'Save & Continue' button is clicked. We