Skip to content

Commit e3ea666

Browse files
SilverDavmmoqui
authored andcommitted
Feature #13573 : See also: improve display order of the publications
in this context : - We don't manage manual order - We don't persist the choosen order
1 parent 6903b46 commit e3ea666

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/servlets/AjaxPublicationsListServlet.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse res) throws I
129129
String nodeId = req.getParameter("Id");
130130
String sToLink = req.getParameter("ToLink");
131131
String topicToLinkId = req.getParameter("TopicToLinkId");
132+
133+
boolean seeAlso = false;
134+
132135
// check if trying to link attachment
133136
boolean attachmentToLink = req.getParameterAsBoolean("attachmentLink");
134137

@@ -191,6 +194,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse res) throws I
191194
if (nbItemsPerPage != null) {
192195
kmeliaSC.setNbPublicationsPerPage(nbItemsPerPage);
193196
}
197+
int previousSort = kmeliaSC.getSort().getCurrentSort();
194198
if (sort != null) {
195199
kmeliaSC.setSortValue(sort);
196200
final String contentLanguage = kmeliaSC.getCurrentLanguage();
@@ -208,18 +212,20 @@ public void doPost(HttpServletRequest request, HttpServletResponse res) throws I
208212

209213
boolean sortAllowed = true;
210214
boolean linksAllowed = true;
211-
boolean seeAlso = false;
212215
List<KmeliaPublication> publications;
213216
TopicDetail currentTopic;
214217
String role = kmeliaSC.getProfile();
215218
if (toLink) {
216219
currentTopic = kmeliaSC.getSessionTopicToLink();
217-
sortAllowed = true;
218220
linksAllowed = false;
219221
seeAlso = true;
220222
// get selected publication ids from session
221223
selectedIds = processPublicationsToLink(req);
222224
kmeliaSC.setCurrentFolderId(currentTopic.getNodePK().getId(), true);
225+
if (sort != null) {
226+
kmeliaSC.getSort().setCurrentSort(sort);
227+
kmeliaSC.getSort().setExplicitSort(true);
228+
}
223229
kmeliaSC.loadPublicationsOfCurrentFolder();
224230
publications = kmeliaSC.getSessionPublicationsList();
225231
} else if (toPortlet) {
@@ -270,6 +276,10 @@ public void doPost(HttpServletRequest request, HttpServletResponse res) throws I
270276
attachmentToLink);
271277
}
272278
}
279+
//We rollback with previous sort of the topic
280+
if (toLink) {
281+
kmeliaSC.getSort().setCurrentSort(previousSort);
282+
}
273283
} catch (IOException e) {
274284
SilverLogger.getLogger(this).error(e);
275285
}
@@ -824,7 +834,6 @@ void displaySortingListBox(MultiSilverpeasBundle resources, KmeliaSessionControl
824834
getSortingListBoxEntry(SORT_MANUAL, resources.getString("kmelia.sort.manual"), ksc));
825835
}
826836
out.write("</select>");
827-
828837
if (manualSort && SilverpeasRole.ADMIN == ksc.getHighestSilverpeasUserRole()) {
829838
// Display link to reset manual sort
830839
Img img = new Img();

kmelia/kmelia-war/src/main/webapp/kmelia/jsp/publicationLinksManager.jsp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108
displayPublications(oArgs.node.data.componentId,getCurrentNodeId());
109109
//displays the publication localized at the root of a theme tracker
110110
}else if (oArgs.node.data.nodeType=='COMPONENT' && oArgs.node.data.id.indexOf('kmelia')==0){
111-
displayPublications(oArgs.node.data.id,rootTopic);
112111
setCurrentNodeId(rootTopic);
112+
displayPublications(oArgs.node.data.id,rootTopic);
113113
}else{
114114
displayHomeMessage();
115115
}
@@ -123,14 +123,18 @@
123123
function sortGoTo(selectedIndex) {
124124
if (selectedIndex !== 0 && selectedIndex !== 1) {
125125
const sort = document.publicationsForm.sortBy[selectedIndex].value;
126-
currentSort = sort;
127126
const ieFix = new Date().getTime();
128127
const componentId = currentComponent;
129-
$.get(getWebContext()+'/RAjaxPublicationsListServlet',
130-
{PubId:pubId,TopicToLinkId:getCurrentNodeId(),ComponentId:componentId, ToLink:1, Sort: sort,IEFix:ieFix},
131-
function(data){
132-
$('#pubList').html(data);
133-
},"html");
128+
$.get(getWebContext() + '/RAjaxPublicationsListServlet', {
129+
TopicToLinkId : getCurrentNodeId(),
130+
ComponentId : componentId,
131+
ToLink : 1,
132+
Sort : sort,
133+
IEFix : ieFix
134+
}, function(data) {
135+
$('#pubList').html(data);
136+
}, "html");
137+
return;
134138
}
135139
}
136140
@@ -144,7 +148,7 @@
144148
145149
function doPagination(index, nbItemsPerPage){
146150
const ieFix = new Date().getTime();
147-
$.get(getWebContext()+'/RAjaxPublicationsListServlet', {PubId:pubId,Index:index,NbItemsPerPage:nbItemsPerPage,ComponentId:currentComponent,ToLink:1,Sort:currentSort,IEFix:ieFix},
151+
$.get(getWebContext()+'/RAjaxPublicationsListServlet', {Index:index,NbItemsPerPage:nbItemsPerPage,ComponentId:currentComponent,ToLink:1,Sort:currentSort,IEFix:ieFix},
148152
function(data){
149153
$('#pubList').html(data);
150154
},"html");
@@ -157,7 +161,7 @@
157161
158162
function displayPublications(CompoId,topicId){
159163
const ieFix = new Date().getTime();
160-
$.get(getWebContext()+'/RAjaxPublicationsListServlet', {PubId:pubId,ComponentId:CompoId,TopicToLinkId:topicId,ToLink:1,Sort:currentSort,IEFix:ieFix},
164+
$.get(getWebContext()+'/RAjaxPublicationsListServlet', {ComponentId:CompoId,TopicToLinkId:topicId,ToLink:1,Sort:currentSort,IEFix:ieFix},
161165
function(data){
162166
$('#pubList').html(data);
163167
},"html");

0 commit comments

Comments
 (0)