Skip to content

Commit 9d2e8ea

Browse files
Merge branch 'feature-4609' of https://github.com/ehsavoie/Silverpeas-Core into ehsavoie-feature-4609
2 parents 9387200 + 05e02f0 commit 9d2e8ea

File tree

4 files changed

+28
-35
lines changed

4 files changed

+28
-35
lines changed

lib-core/src/main/java/org/silverpeas/attachment/repository/DocumentRepository.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,15 @@ public SimpleDocumentPK changeVersionState(Session session, SimpleDocumentPK doc
351351
if (StringUtil.isDefined(comment)) {
352352
documentNode.setProperty(SLV_PROPERTY_COMMENT, comment);
353353
}
354+
SimpleDocument origin = converter.fillDocument(documentNode, I18NHelper.defaultLanguage);
354355
if (versionedNode) {
355356
removeHistory(documentNode);
356357
documentNode.removeMixin(MIX_SIMPLE_VERSIONABLE);
357358
documentNode.setProperty(SLV_PROPERTY_VERSIONED, false);
359+
documentNode.setProperty(SLV_PROPERTY_MAJOR, 0);
360+
documentNode.setProperty(SLV_PROPERTY_MINOR, 0);
358361
SimpleDocument target = converter.fillDocument(documentNode, I18NHelper.defaultLanguage);
362+
moveMultilangContent(origin, target);
359363
File currentDocumentDir = new File(target.getDirectoryPath(I18NHelper.defaultLanguage))
360364
.getParentFile();
361365
File[] contents = currentDocumentDir.getParentFile().listFiles();
@@ -365,13 +369,11 @@ public SimpleDocumentPK changeVersionState(Session session, SimpleDocumentPK doc
365369
}
366370
}
367371
} else {
368-
SimpleDocument origin = converter.fillDocument(documentNode, I18NHelper.defaultLanguage);
369372
documentNode.setProperty(SLV_PROPERTY_VERSIONED, true);
370373
documentNode.setProperty(SLV_PROPERTY_MAJOR, 1);
371374
documentNode.setProperty(SLV_PROPERTY_MINOR, 0);
372375
documentNode.addMixin(MIX_SIMPLE_VERSIONABLE);
373376
SimpleDocument target = converter.fillDocument(documentNode, I18NHelper.defaultLanguage);
374-
375377
VersionManager versionManager = documentNode.getSession().getWorkspace().getVersionManager();
376378
documentNode.getSession().save();
377379
moveMultilangContent(origin, target);

lib-core/src/test/java/org/silverpeas/attachment/repository/HistorisedDocumentRepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ public void testChangeVersionStateOfVersionedDocument() throws Exception {
11981198
assertThat(simplifiedDocument.getContentType(), is(MimeTypes.MIME_TYPE_OO_PRESENTATION));
11991199
assertThat(simplifiedDocument.getSize(), is(28L));
12001200
assertThat(simplifiedDocument.getMajorVersion(), is(0));
1201-
assertThat(simplifiedDocument.getMinorVersion(), is(2));
1201+
assertThat(simplifiedDocument.getMinorVersion(), is(0));
12021202
assertThat(simplifiedDocument.isVersioned(), is(false));
12031203
assertThat(simplifiedDocument.getComment(), is("To simple document"));
12041204
} finally {

war-core/src/main/webapp/attachment/jsp/displayAttachedFiles.jsp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,8 @@
485485
oMenu.getItem(2).cfg.setProperty("disabled", true);
486486
}
487487
//disable delete
488-
<c:choose>
489-
<c:when test="${useXMLForm}">oMenu.getItem(2, 1).cfg.setProperty("disabled", true);</c:when>
490-
<c:otherwise>oMenu.getItem(1, 1).cfg.setProperty("disabled", true);</c:otherwise>
491-
</c:choose>
492-
oMenu.getItem(1,2).cfg.setProperty("disabled", true);
488+
oMenu.getItem(4, 1).cfg.setProperty("disabled", true);
489+
oMenu.getItem(3, 1).cfg.setProperty("disabled", true);
493490
$('#worker' + oldId).html("<fmt:message key="readOnly"/> <%=m_MainSessionCtrl.getCurrentUserDetail().getDisplayedName()%> <fmt:message key="at"/> <%=DateUtil.getOutputDate(new Date(), language)%>");
494491
$('#worker' + oldId).css({'visibility':'visible'});
495492
if (edit) {
@@ -519,11 +516,15 @@
519516
function switchState(id, isVersioned) {
520517
<fmt:message key="attachment.switch.warning.simple" var="warningSimple"/>
521518
<fmt:message key="attachment.switch.warning.versioned" var="warningVersioned"/>
519+
<fmt:message key="attachment.switchState.toVersioned" var="warningTitleSimple"/>
520+
<fmt:message key="attachment.switchState.toSimple" var="warningTitleVersioned"/>
522521
if(isVersioned) {
522+
$("#dialog-attachment-switch").dialog( "option" , 'title' , '<c:out value="${silfn:escapeJs(warningTitleVersioned)}" />' );
523523
$("#attachment-switch-warning-message").empty().append('<c:out value="${silfn:escapeJs(warningSimple)}" />');
524524
$("#attachment-switch-versioned").hide();
525525
$("#attachment-switch-simple").show();
526526
} else {
527+
$("#dialog-attachment-switch").dialog( "option" , 'title' , '<c:out value="${silfn:escapeJs(warningTitleSimple)}" />' );
527528
$("#attachment-switch-warning-message").empty().append('<c:out value="${silfn:escapeJs(warningVersioned)}" />');
528529
$("#attachment-switch-simple").hide();
529530
$("#attachment-switch-versioned").show();
@@ -550,12 +551,8 @@
550551
oMenu.getItem(0).cfg.setProperty("disabled", false);
551552
oMenu.getItem(1).cfg.setProperty("disabled", false);
552553
oMenu.getItem(2).cfg.setProperty("disabled", false);
553-
//enable delete
554-
<c:choose>
555-
<c:when test="${useXMLForm}">oMenu.getItem(2, 1).cfg.setProperty("disabled", false);</c:when>
556-
<c:otherwise>oMenu.getItem(1, 1).cfg.setProperty("disabled", false);</c:otherwise>
557-
</c:choose>
558-
oMenu.getItem(1,2).cfg.setProperty("disabled", false);
554+
oMenu.getItem(4, 1).cfg.setProperty("disabled", false)
555+
oMenu.getItem(3, 1).cfg.setProperty("disabled", false);
559556
$('#worker' + id).html("");
560557
$('#worker' + id).css({'visibility':'hidden'});
561558
if (pageMustBeReloadingAfterSorting) {
@@ -1154,7 +1151,7 @@
11541151
<form name="attachment-switch-form" id="attachment-switch-form" method="put" accept-charset="UTF-8">
11551152
<div id="attachment-switch-simple" style="display:none">
11561153
<label for="switch-version-major" class="label-ui-dialog"><fmt:message key="attachment.switch.version.major" /></label>
1157-
<span id="attachment-switch-major" class="champ-ui-dialog"><input value="lastMajor" type="radio" name="switch-version" id="switch-version-major"/></span>
1154+
<span id="attachment-switch-major" class="champ-ui-dialog"><input value="lastMajor" type="radio" name="switch-version" id="switch-version-major" checked="checked"/></span>
11581155
<label for="switch-version-last" class="label-ui-dialog"><fmt:message key="attachment.switch.version.last" /></label>
11591156
<span id="attachment-switch-last" class="champ-ui-dialog"><input value="last" type="radio" name="switch-version" id="switch-version-last"/></span>
11601157
</div>

web-core/src/main/java/org/silverpeas/attachment/tag/SimpleDocumentContextualMenu.java

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,21 @@ String prepareActions(SimpleDocument attachment, boolean useXMLForm,
150150
builder.append("<ul>").append(newline);
151151
prepareMenuItem(builder, "updateAttachment('" + attachment.getId() + "','" + language + "');",
152152
resources.getString("GML.modify"));
153-
if (useXMLForm) {
154-
prepareMenuItem(builder, "EditXmlForm('" + attachment.getId() + "','" + language + "');",
155-
resources.getString("attachment.xmlForm.Edit"));
153+
prepareMenuItem(builder, "EditXmlForm('" + attachment.getId() + "','" + language + "');",
154+
resources.getString("attachment.xmlForm.Edit"));
155+
String message = resources.getString("attachment.switchState.toVersioned");
156+
if (attachment.isVersioned()) {
157+
message = resources.getString("attachment.switchState.toSimple");
156158
}
159+
prepareMenuItem(builder, "switchState('" + attachment.getId() + "', " + attachment.isVersioned()
160+
+ ");", message);
157161
prepareMenuItem(builder, "deleteAttachment('" + attachment.getId() + "','" + StringEscapeUtils
158162
.escapeEcmaScript(attachment.getFilename()) + "');", resources.getString("GML.delete"));
159163
builder.append("</ul>").append(newline);
160164
builder.append("<ul>").append(newline);
161165
prepareMenuItem(builder, "ShareAttachment('" + attachment.getId() + "');", resources.getString(
162166
"attachment.share"));
163-
String message = resources.getString("attachment.switchState.toVersioned");
164-
if (attachment.isVersioned()) {
165-
message = resources.getString("attachment.switchState.toSimple");
166-
}
167-
prepareMenuItem(builder, "switchState('" + attachment.getId() + "', " + attachment.isVersioned()
168-
+ ");", message);
167+
169168
builder.append("</ul>").append(newline);
170169
builder.append("<ul>").append(newline);
171170
prepareMenuItem(builder, "notifyAttachment('" + attachmentId + "');", resources.getString(
@@ -202,14 +201,12 @@ String prepareActions(SimpleDocument attachment, boolean useXMLForm,
202201
builder.append(configureCheckin(attachmentId, !isWorker(userId, attachment)
203202
&& !isAdmin(userId)));
204203
builder.append(configureUpdate(attachmentId, !isWorker(userId, attachment)));
205-
builder.append(configureDelete(attachmentId, useXMLForm, true));
204+
builder.append(configureDelete(attachmentId, true));
206205
if (!userId.equals(attachment.getEditedBy())) {
207-
// disable xmlForm
208-
if (useXMLForm) {
209-
builder.append(configureXmlForm(attachmentId, true));
210-
}
206+
builder.append(configureXmlForm(attachmentId, true));
211207
}
212208
} else {
209+
builder.append(configureXmlForm(attachmentId, !useXMLForm));
213210
builder.append(configureCheckin(attachmentId, true));
214211
builder.append(configureCheckoutAndEdit(attachmentId, !useWebDAV || !attachment.
215212
isOpenOfficeCompatible()));
@@ -261,11 +258,8 @@ String configureUpdate(String attachmentId, boolean disable) {
261258
return String.format(template, attachmentId, "0, 1", disable);
262259
}
263260

264-
String configureDelete(String attachmentId, boolean useXmlForm, boolean disable) {
265-
if (useXmlForm) {
266-
return String.format(template, attachmentId, "2, 1", disable);
267-
}
268-
return String.format(template, attachmentId, "1, 1", disable);
261+
String configureDelete(String attachmentId, boolean disable) {
262+
return String.format(template, attachmentId, "4, 1", disable);
269263
}
270264

271265
String configureXmlForm(String attachmentId, boolean disable) {
@@ -277,7 +271,7 @@ String configureFileSharing(String attachmentId, boolean disable) {
277271
}
278272

279273
String configureSwitchState(String attachmentId, boolean disable) {
280-
return String.format(template, attachmentId, "1, 2", disable);
274+
return String.format(template, attachmentId, "3, 1", disable);
281275
}
282276

283277
String configureNotify(String attachmentId, boolean disable) {

0 commit comments

Comments
 (0)