Modifiche per il documento Office Importer
Dalla versione 3.1
modificato da Nazzareno Pompei
il 30/01/2023 10:31
il 30/01/2023 10:31
Cambia il commento:
Install extension [org.xwiki.platform:xwiki-platform-office-ui/14.10.3]
Summary
-
Page properties (2 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 1 removed)
Details
- Page properties
-
- Autore del documento
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.N azzarenoPompei1 +XWiki.NPompei - Content
-
... ... @@ -1,294 +1,144 @@ 1 -{{velocity output="false"}} 2 -#macro (officeImporterForm) 1 +{{velocity}} 2 +#set($displayDocExtra = false) 3 +#if ($isguest) 4 + {{error}}$services.localization.render('xe.officeimporter.notallowed'){{/error}} 5 +#elseif (!$services.officemanager.isConnected()) 6 + #if ($hasAdmin) 7 + {{error}}$services.localization.render('xe.officeimporter.error.adminuser', ['[[', '>>http://extensions.xwiki.org/xwiki/bin/Extension/Office%20Importer%20Application]]']){{/error}} 8 + #else 9 + {{error}}$services.localization.render('xe.officeimporter.error.normaluser'){{/error}} 10 + #end 11 +#elseif("$!request.page" == '') 12 + ## This page does not propose to select the target page anymore. We redirect to the create action instead 13 + ## Note: we make the URL from the main page and not from the current one. Because the user have probably not the 14 + ## create right on the "XWiki" space, and this space should be reserved for technical usage. 15 + {{error}}$services.localization.render('office.form.error.noDocument', ['[[', ">>path:$xwiki.getURL($services.wiki.currentWikiDescriptor.mainPageReference, 'create', 'type=office')]]"]){{/error}} 16 +#else 3 3 #set ($targetReference = $services.model.resolveDocument($request.page)) 4 - #set ($targetPageIsNested = $targetReference.name == $services.model.getEntityReference('DOCUMENT', 'default').name) 5 - #set ($discard = $xwiki.ssx.use('XWiki.OfficeImporter')) 18 + #set ($targetDoc = $xwiki.getDocument($targetReference)) 6 6 #set ($discard = $xwiki.jsx.use('XWiki.OfficeImporter')) 7 - {{html clean="false"}} 8 - <form id="officeImportForm" class="xform" method="post" enctype="multipart/form-data" 9 - action="$escapetool.xml($xwiki.getURL('XWiki.OfficeImporterResults'))" 10 - data-progress-message="$escapetool.xml($services.localization.render('office.import.inProgress'))" 11 - data-done-message="$escapetool.xml($services.localization.render('office.import.done'))" 12 - data-failed-message="$escapetool.xml($services.localization.render('office.import.failed'))"> 13 - <fieldset> 14 - <dl class="row"> 15 - ## 16 - ## Left part 17 - ## 18 - <div class="col-xs-12 col-md-6"> 19 - #officeImporterForm_officeDocument() 20 - #officeImporterForm_targetPage() 21 - #if ($xwiki.exists($targetReference)) 22 - #officeImporterForm_overwriteContent() 23 - #end 24 - </div> 25 - ## 26 - ## Right part 27 - ## 28 - <div class="col-xs-12 col-md-6"> 29 - #officeImporterForm_filterStyles() 30 - #officeImporterForm_splitDocument() 31 - #officeImporterForm_headingLevelsToSplit() 32 - #officeImporterForm_childPagesNamingMethod() 33 - #officeImporterForm_terminalChildPages() 34 - </div> 35 - </dl> 20 + #set ($discard = $xwiki.jsfx.use('uicomponents/widgets/validation/livevalidation_prototype.js')) 21 + #set ($discard = $xwiki.ssfx.use('uicomponents/widgets/validation/livevalidation.css', true)) 22 + 23 +{{html}} 24 +<form action="$xwiki.getURL('XWiki.OfficeImporterResults','view')" enctype="multipart/form-data" method="post" class="xform" id="officeImportForm"> 25 + <dl class="row"> 26 + ## 27 + ## Left part 28 + ## 29 + <div class="col-xs-12 col-md-6"> 36 36 ## 37 - ## Hiddeninputs31 + ## Document 38 38 ## 39 - < input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" />40 - ##Normalizeparentreferencefthenewdocument sohatevenin a subwiki itpoints tothecurrentwiki.41 - #set ($normalizedParentReference = $services.model.resolveDocument("$!request.parent", 'current'))42 - < input type="hidden"name="parent" value="$escapetool.xml($normalizedParentReference)"/>43 - <input type=" hidden" name="target" value="$escapetool.xml($services.model.serialize($targetReference,44 - 'default'))"/>33 + <dt> 34 + <label for="filepath">$escapetool.xml($services.localization.render('xe.officeimporter.import.document'))</label> 35 + </dt> 36 + <dd class="buttonwrapper"> 37 + <input id="filepath" type="file" name="filePath" value="" size="40" class="button secondary" /> 38 + </dd> 45 45 ## 46 - ## Formaction buttons40 + ## Target 47 47 ## 48 - <div class="buttons"> 49 - <span class="buttonwrapper"> 50 - <button id="submit"> 51 - $escapetool.xml($services.localization.render('xe.officeimporter.import.import')) 52 - </button> 53 - </span> 54 - <span class="buttonwrapper"> 55 - <a class="secondary button" href="$escapetool.xml($xwiki.getURL($targetReference))"> 56 - $escapetool.xml($services.localization.render('cancel')) 57 - </a> 58 - </span> 59 - </div> 60 - </fieldset> 61 - </form> 62 - {{/html}} 63 -#end 64 - 65 -#macro (officeImporterForm_officeDocument) 66 - ## FIXME: The following list of file name extensions and media types are duplicated from the office resource reference 67 - ## picker (templates/html_displayer/officeresourcereference/edit.vm). 68 - #set ($officeFileNameExtensions = $stringtool.join([ 69 - '.doc', '.docx', 70 - '.xls', '.xlsx', 71 - '.ppt', '.pptx', 72 - '.odt', '.ott', '.fodt', 73 - '.ods', '.ots', '.fods', 74 - '.odp', '.otp', '.fodp', 75 - '.sxw', '.sxc', '.sxi' 76 - ], ',')) 77 - #set ($officeMediaTypes = $stringtool.join([ 78 - 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 79 - 'application/vnd.oasis.opendocument.', 80 - 'application/vnd.openxmlformats-officedocument.', 81 - 'application/vnd.sun.xml.' 82 - ], ',')) 83 - <dt> 84 - <label for="filePath"> 85 - $escapetool.xml($services.localization.render('xe.officeimporter.import.document')) 86 - </label> 87 - <span class="xHint"> 88 - $escapetool.xml($services.localization.render('office.import.document.hint')) 89 - </span> 90 - </dt> 91 - <dd class="buttonwrapper"> 92 - <input type="file" id="filePath" name="filePath" value="" size="40" class="button secondary" required 93 - accept="$escapetool.xml("$officeFileNameExtensions,$officeMediaTypes")" /> 94 - </dd> 95 -#end 96 - 97 -#macro (officeImporterForm_targetPage) 98 - <dt> 99 - <label> 100 - $escapetool.xml($services.localization.render('xe.officeimporter.import.target')) 101 - </label> 102 - <span class="xHint"> 103 - $escapetool.xml($services.localization.render('office.import.target.hint')) 104 - </span> 105 - </dt> 106 - <dd> 107 - #template('hierarchy_macros.vm') 108 - #hierarchy($targetReference) 109 - </dd> 110 -#end 111 - 112 -#macro (officeImporterForm_overwriteContent) 113 - <dt class="box warningmessage"> 114 - <label> 115 - <input name="overwriteContent" type="checkbox" value="true" checked /> 116 - $escapetool.xml($services.localization.render('office.import.overwriteContent')) 117 - </label> 118 - <span class="xHint"> 119 - $escapetool.xml($services.localization.render('office.import.overwriteContent.hint')) 120 - </span> 121 - </dt> 122 - <dd> 123 - #officeImporterForm_confirmationModal({ 124 - 'cssClass': 'confirmation-overwriteContent', 125 - 'title': 'office.import.overwriteContent', 126 - 'message': 'office.import.overwriteContent.confirmationMessage', 127 - 'action': 'office.import.overwriteContent.confirmationAction' 128 - }) 129 - </dd> 130 -#end 131 - 132 -#macro (officeImporterForm_confirmationModal $config) 133 - <div class="confirmation modal fade $!escapetool.xml($config.cssClass)" tabindex="-1" role="dialog"> 134 - <div class="modal-dialog"> 135 - <div class="modal-content"> 136 - <div class="modal-header"> 137 - <button type="button" class="close" data-dismiss="modal">×</button> 138 - <div class="modal-title"> 139 - $escapetool.xml($services.localization.render($config.title)) 140 - </div> 141 - </div> 142 - <div class="modal-body"> 143 - $escapetool.xml($services.localization.render($config.message)) 144 - </div> 145 - <div class="modal-footer"> 146 - <input type="button" class="btn btn-danger" data-dismiss="modal" 147 - value="$escapetool.xml($services.localization.render($config.action))"> 148 - <input type="button" class="btn btn-default" data-dismiss="modal" 149 - value="$escapetool.xml($services.localization.render('cancel'))"> 150 - </div> 151 - </div> 42 + <dt> 43 + <label>Target</label> 44 + </dt> 45 + <dd> 46 + #template('hierarchy_macros.vm') 47 + #hierarchy($targetReference) 48 + </dd> 49 + ## 50 + ## Append result 51 + ## 52 + #if (!$targetDoc.isNew()) 53 + <dt class="warningmessage"> 54 + <label for="appendContentInputId">$escapetool.xml($services.localization.render('xe.officeimporter.import.appendresult'))</label> 55 + <span class="xHint">$escapetool.xml($services.localization.render('office.form.append.hint'))</span> 56 + </dt> 57 + <dd class="warningmessage"> 58 + <input id="appendContentInputId" name="appendContent" type="checkbox" value="true" /> 59 + </dd> 60 + #end 152 152 </div> 153 - </div> 154 -#end 155 - 156 -#macro (officeImporterForm_filterStyles) 157 - <dt> 158 - <label> 159 - <input name="filterStyles" type="checkbox" value="strict" checked /> 160 - $escapetool.xml($services.localization.render('xe.officeimporter.import.filterstyles')) 161 - </label> 162 - <span class="xHint"> 163 - $escapetool.xml($services.localization.render('xe.officeimporter.import.help.styles')) 164 - </span> 165 - </dt> 166 - <dd></dd> 167 -#end 168 - 169 -#macro (officeImporterForm_splitDocument) 170 - <dt> 171 - <label> 172 - <input name="splitDocument" type="checkbox" value="true" /> 173 - $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.splitdocument')) 174 - </label> 175 - <span class="xHint"> 176 - $escapetool.xml($services.localization.render('xe.officeimporter.import.help.splitting')) 177 - </span> 178 - </dt> 179 - <dd></dd> 180 -#end 181 - 182 -#macro (officeImporterForm_headingLevelsToSplit) 183 - <dt> 184 - <label for="headingLevelsToSplitInputId"> 185 - $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.headinglevels')) 186 - </label> 187 - <span class="xHint"> 188 - $escapetool.xml($services.localization.render('office.import.headingLevelsToSplit.hint')) 189 - </span> 190 - </dt> 191 - <dd> 192 - <select id="headingLevelsToSplitInputId" name="headingLevelsToSplit" multiple required size="6" 193 - class="splitDocument-setting"> 194 - #foreach ($level in [1..6]) 195 - <option value="$level"#if ($level == 1) selected#end> 196 - $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.heading')) $level 197 - </option> 62 + ## 63 + ## Right part 64 + ## 65 + <div class="col-xs-12 col-md-6"> 66 + ## 67 + ## Styles 68 + ## 69 + <dt> 70 + <label for="filterStylesInputId">$escapetool.xml($services.localization.render('xe.officeimporter.import.filterstyles'))</label> 71 + <span class="xHint">$escapetool.xml($services.localization.render('xe.officeimporter.import.help.styles'))</span> 72 + </dt> 73 + <dd> 74 + <input id="filterStylesInputId" name="filterStyles" type="checkbox" value="strict" checked="checked"/> 75 + </dd> 76 + ## 77 + ## Splitting 78 + ## 79 + <dt> 80 + <label for="splitDocumentInputId">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.splitdocument'))</label> 81 + <span class="xHint">$escapetool.xml($services.localization.render('xe.officeimporter.import.help.splitting'))</span> 82 + </dt> 83 + <dd> 84 + <input id="splitDocumentInputId" name="splitDocument" type="checkbox" value="true"/> 85 + </dd> 86 + ## 87 + ## Heading level splits 88 + ## 89 + <dt> 90 + <label for="headingLevelsToSplitInputId" class="multipleselect">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.headinglevels'))</label> 91 + </dt> 92 + <dd> 93 + <select id="headingLevelsToSplitInputId" size="5" multiple="multiple" name="headingLevelsToSplit"> 94 + #foreach($h in [1..6]) 95 + <option value="${h}"#if ($foreach.count == 1) selected="selected"#end>$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.heading'))-${h}</option> 96 + #end 97 + </select> 98 + </dd> 99 + ## 100 + ## Child pages naming method: 101 + ## 102 + #if ($targetDoc.documentReference.name == 'WebHome') 103 + ## When the target page is not terminal, the only logical strategy to use is "headingNames". It creates pages 104 + ## as children of the target, which seems to be the correct way in the nested pages paradigm. 105 + ## The other choices have no sense: 106 + ## - "mainPageNameAndHeading" will create pages called "WebHome-Title1" instead of "targetDoc/Title1". 107 + ## - "mainPageNameAndNumbering" will create pages called "WebHome-1" instead of "targetDoc/1". 108 + ## In both cases, the "WebHome" part of the names are meaningless. 109 + ## 110 + ## NOTE: The created children are terminal until https://jira.xwiki.org/browse/XWIKI-12569 is fixed. 111 + <input type="hidden" name="childPagesNamingMethod" value="headingNames" /> 112 + #else 113 + <dt> 114 + <label for="childPagesNamingMethodInputId">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming'))</label> 115 + </dt> 116 + <dd> 117 + <select id="childPagesNamingMethodInputId" name="childPagesNamingMethod"> 118 + <option value="headingNames">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming.headingnames'))</option> 119 + <option value="mainPageNameAndHeading">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming.mainpagenameandheading'))</option> 120 + <option value="mainPageNameAndNumbering">$escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming.mainpagenameandnumbering'))</option> 121 + </select> 122 + </dd> 198 198 #end 199 - </select> 200 - </dd> 124 + </div> 125 + </dl> 126 + <div class="clearfloats"></div> 127 + ## 128 + ## Hidden inputs 129 + ## 130 + <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> 131 + ## Normalize the parent reference of the new document so that even in a subwiki it points to the current wiki 132 + #set ($normalizedParentReference = $services.model.resolveDocument("$!request.parent", 'current')) 133 + <input type="hidden" name="parent" value="$normalizedParentReference" /> 134 + <input type="hidden" name="target" value="$escapetool.xml($services.model.serialize($targetReference, 'default'))" id="target"/> 135 + ## 136 + ## Confirm button 137 + ## 138 + <span class="buttonwrapper"> 139 + <input type="submit" value="$services.localization.render('xe.officeimporter.import.import')" class="button" id="submit"/> 140 + </span> 141 +</form> 142 +{{/html}} 201 201 #end 202 - 203 -#macro (officeImporterForm_childPagesNamingMethod) 204 - ## Hide the field when the target page is nested (not terminal) because the only logical strategy in this case is to 205 - ## use "headingNames". It creates pages as children of the target, which seems to be the correct way in the nested 206 - ## pages paradigm. The other choices have no sense: 207 - ## - "mainPageNameAndHeading" will create pages called "WebHome-Title1" instead of "targetPage/Title1". 208 - ## - "mainPageNameAndNumbering" will create pages called "WebHome-1" instead of "targetPage/1". 209 - ## In both cases, the "WebHome" part of the names is meaningless. 210 - <dt#if ($targetPageIsNested) hidden#end> 211 - <label for="childPagesNamingMethodInputId"> 212 - $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming')) 213 - </label> 214 - <span class="xHint"> 215 - $escapetool.xml($services.localization.render('office.import.childPagesNaming.hint')) 216 - </span> 217 - </dt> 218 - <dd> 219 - <select id="childPagesNamingMethodInputId" name="childPagesNamingMethod" class="splitDocument-setting" 220 - #if ($targetPageIsNested) hidden#end> 221 - <option value="headingNames"#if ($targetPageIsNested) selected#end> 222 - $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming.headingnames')) 223 - </option> 224 - <option value="mainPageNameAndHeading"#if (!$targetPageIsNested) selected#end> 225 - $escapetool.xml($services.localization.render( 226 - 'xe.officeimporter.import.splitting.naming.mainpagenameandheading')) 227 - </option> 228 - <option value="mainPageNameAndNumbering"> 229 - $escapetool.xml($services.localization.render( 230 - 'xe.officeimporter.import.splitting.naming.mainpagenameandnumbering')) 231 - </option> 232 - </select> 233 - </dd> 234 -#end 235 - 236 -#macro (officeImporterForm_terminalChildPages) 237 - #set ($hidden = !($targetPageIsNested && ($isAdvancedUser || $isSuperAdmin))) 238 - <dt#if ($hidden) hidden#end> 239 - <label> 240 - <input type="checkbox" name="terminalChildPages" value="true"#if ($hidden) checked#end 241 - class="splitDocument-setting" /> 242 - $escapetool.xml($services.localization.render('office.import.terminalChildPages')) 243 - </label> 244 - <span class="xHint"> 245 - $escapetool.xml($services.localization.render('office.import.terminalChildPages.hint')) 246 - </span> 247 - </dt> 248 - <dd></dd> 249 -#end 250 - 251 -#macro (officeImporter_translationWithLink $key $linkTarget) 252 - #set ($targetSyntax = 'xwiki/2.1') 253 - #set ($translation = $services.localization.render($key, $targetSyntax, ['LINKSTART', 'LINKEND'])) 254 - #set ($linkLabel = $stringtool.substringBetween($translation, 'LINKSTART', 'LINKEND')) 255 - #if ($linkLabel) 256 - #set ($escapedLinkLabel = $services.rendering.escape($linkLabel, $targetSyntax)) 257 - #set ($escapedLinkTarget = $services.rendering.escape($linkTarget, $targetSyntax)) 258 - $translation.replace("LINKSTART${linkLabel}LINKEND", "[[$escapedLinkLabel>>$escapedLinkTarget]]") 259 - #else 260 - $services.localization.render($key, $targetSyntax, ['', '']) 261 - #end 262 -#end 263 263 {{/velocity}} 264 - 265 -{{velocity}} 266 -#if ("$!request.page" == '') 267 - {{error}} 268 - ## This page does not propose to select the target page anymore. The create action should be used instead. 269 - ## Note: The link points to the main page because the user might not have create right on the current "XWiki" space, 270 - ## which is reserved anyway for technical pages. 271 - #set ($createURL = $xwiki.getURL($services.wiki.currentWikiDescriptor.mainPageReference, 'create', 'type=office')) 272 - #officeImporter_translationWithLink('office.form.error.noDocument' "path:$createURL") 273 - {{/error}} 274 -#else 275 - ## Hide UI elements that are not needed for office import. 276 - #set ($displayContentMenu = false) 277 - #set ($displayContentFooter = false) 278 - #set ($displayDocExtra = false) 279 - #if ($isguest) 280 - {{error}}$services.localization.render('xe.officeimporter.notallowed', 'xwiki/2.1'){{/error}} 281 - #elseif (!$services.officemanager.isConnected()) 282 - #if ($hasAdmin) 283 - {{error}} 284 - #set ($documentationURL = 'http://extensions.xwiki.org/xwiki/bin/Extension/Office%20Importer%20Application') 285 - #officeImporter_translationWithLink('xe.officeimporter.error.adminuser' $documentationURL) 286 - {{/error}} 287 - #else 288 - {{error}}$services.localization.render('xe.officeimporter.error.normaluser', 'xwiki/2.1'){{/error}} 289 - #end 290 - #else 291 - #officeImporterForm() 292 - #end 293 -#end 294 -{{/velocity}}
- XWiki.JavaScriptExtension[0]
-
- Codice
-
... ... @@ -1,80 +1,59 @@ 1 -require(['jquery', 'bootstrap'], function($) { 2 - /** 3 - * Enable/disable the split document settings based on the value of the split document checkbox. 4 - */ 5 - const maybeDisableSplitDocumentSettings = function() { 6 - const splitDocumentDisabled = !$('input[name=splitDocument]').prop('checked'); 7 - $('.splitDocument-setting').prop('disabled', splitDocumentDisabled); 8 - }; 9 - 10 - // Initalize the default state. 11 - maybeDisableSplitDocumentSettings(); 12 - 13 - // Enable/disable the split document settings when the checkbox's value changes. 14 - $('input[name=splitDocument]').on('change', maybeDisableSplitDocumentSettings); 15 - 16 - /** 17 - * Handle form submit. 18 - */ 19 - $('#officeImportForm').on('submit', function(event) { 20 - event.preventDefault(); 21 - 22 - const overwriteContentCheckbox = $('input[name=overwriteContent]'); 23 - if (!overwriteContentCheckbox.prop('checked') || overwriteContentCheckbox.data('confirmed')) { 24 - importOfficeDocument($(event.target)); 25 - } else { 26 - // Ask for confirmation to overwrite the content of the target page. 27 - $('.modal.confirmation-overwriteContent').modal(); 1 +require(['jquery'], function($) { 2 + $(document).ready(function() { 3 + 4 + // Add a validator on the document input 5 + var documentValidator = new LiveValidation($('#filepath')[0], { 6 + validMessage: "$services.localization.render('core.validation.valid.message')" 7 + }); 8 + documentValidator.displayMessageWhenEmpty = true; 9 + documentValidator.add(Validate.Custom, { 10 + failureMessage: "$services.localization.render('core.validation.required.message')", 11 + against: function(value) { 12 + return typeof value === 'string' && value.strip().length > 0; 13 + } 14 + }); 15 + 16 + /** 17 + * Enable/disable the split option depending of the value of the split document checkbox 18 + */ 19 + var maybeDisableSplitOptions = function () { 20 + var splitOptionsDisabled = !$('#splitDocumentInputId').prop('checked'); 21 + $('#headingLevelsToSplitInputId').prop('disabled', splitOptionsDisabled); 22 + $('#childPagesNamingMethodInputId').prop('disabled', splitOptionsDisabled); 28 28 } 29 - }); 30 - 31 - $('.modal.confirmation-overwriteContent .btn-danger').on('click', function(event) { 32 - // Remember the confirmation. 33 - $('input[name=overwriteContent]').data('confirmed', true); 34 - // Re-submit the form. 35 - $('#officeImportForm #submit').click(); 36 - }); 37 - 38 - const importOfficeDocument = function(form) { 39 - // Collect the form data before disabling the form. 40 - const formData = new FormData(form[0]); 41 - // Disable the form while the office document is being imported (to prevent the form from being re-submitted). 42 - form.children('fieldset').prop('disabled', true); 43 - // Let the user know that the import is in progress. 44 - $('body').css('cursor', 'wait'); 45 - const notification = new XWiki.widgets.Notification(form.data('progressMessage'), 'inprogress'); 46 - // Send the office import request. 47 - fetch(new XWiki.Document('OfficeImporterResults', 'XWiki').getURL('get'), { 48 - method: 'POST', 49 - body: formData 50 - }).then( 51 - response => response.text() 52 - ).then(html => { 53 - if (html.indexOf('infomessage') > 0) { 54 - // Office import successful. 55 - notification.replace(new XWiki.widgets.Notification(form.data('doneMessage'), 'done')); 56 - // Redirect to the target page. 57 - const targetPageReference = XWiki.Model.resolve(formData.get('target'), XWiki.EntityType.DOCUMENT, 58 - XWiki.currentDocument.documentReference); 59 - window.location.href = new XWiki.Document(targetPageReference).getURL(); 60 - } else { 61 - // Extract the error message from the returned HTML. 62 - const errorMessage = $('<div></div>').html(html).text(); 63 - return Promise.reject(errorMessage); 24 + 25 + // Initalize the default state 26 + maybeDisableSplitOptions(); 27 + 28 + // Enable/disable the split options when the checkbox's value changes 29 + $('#splitDocumentInputId').change(maybeDisableSplitOptions); 30 + 31 + /** 32 + * Event sent when the form is submitted 33 + */ 34 + $('#officeImportForm').submit(function(event) { 35 + // Verify that the target document does not already exist 36 + var appendContentCheckbox = $('#appendContentInputId'); 37 + if (appendContentCheckbox.length == 0 || appendContentCheckbox.prop('checked')) { 38 + // Except if the "append content" checkbox is enabled or if it is not present! 39 + return true; 64 64 } 65 - }).catch(error => { 66 - let failedMessage = form.data('failedMessage'); 67 - if (error) { 68 - failedMessage += `: ${error}`; 69 - } 70 - notification.replace(new XWiki.widgets.Notification(failedMessage, 'error')); 71 - }).finally(() => { 72 - // Re-enable the office import. 73 - form.children('fieldset').prop('disabled', false); 74 - $('body').css('cursor', ''); 41 + 42 + // The document exist 43 + new XWiki.widgets.ConfirmationBox({ 44 + onYes: function() { 45 + // Enable the append result checkbox 46 + $('#appendContentInputId').prop('checked', true); 47 + // Re-send the formular 48 + $('#submit').click(); 49 + } 50 + }, { 51 + confirmationText: "$escapetool.javascript($services.localization.render('platform.office.importDocumentOverwriteConfirmation'))" 52 + }); 53 + 54 + return false; 75 75 }); 76 - }; 77 - 78 - // Everything is ready. 79 - $('#officeImportForm #submit').attr('data-ready', true); 56 + 57 + }); 80 80 }); 59 + - Analizza il contenuto
-
... ... @@ -1,1 +1,1 @@ 1 - No1 +Sì
- XWiki.StyleSheetExtension[0]
-
- Criteri della cache
-
... ... @@ -1,1 +1,0 @@ 1 -long - Codice
-
... ... @@ -1,4 +1,0 @@ 1 -.xdocLastModification, 2 -#hierarchy.breadcrumb { 3 - display: none; 4 -} - Usa questa estensione
-
... ... @@ -1,1 +1,0 @@ 1 -onDemand - Analizza il contenuto
-
... ... @@ -1,1 +1,0 @@ 1 -No - Content Type
-
... ... @@ -1,1 +1,0 @@ 1 -LESS