Skip to content
Snippets Groups Projects
Commit 0d54ffcc authored by srosse's avatar srosse
Browse files

OO-533: small fix, better update of the GUI after list rename, delete, item delete...

parent cb81e68a
No related branches found
No related tags found
No related merge requests found
......@@ -589,6 +589,24 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle
}
}
}
// allSelectedIndex is a flag which is not updated if someone
// deselect a row. check if the num of selected rows is equal
// to the number of loaded rows
if(allSelectedIndex) {
int manuallySelectedRows = multiSelectedIndex.size();
int modelCount = dataModel.getRowCount();
int loadedRows = 0;
for(int i=0; i<modelCount; i++) {
if(dataModel.isRowLoaded(i)) {
loadedRows++;
}
}
if(manuallySelectedRows != loadedRows) {
allSelectedIndex = false;
}
}
}
@Override
......
......@@ -339,6 +339,7 @@ public class QuestionListController extends AbstractItemListController implement
} else if(source == bulkChangeCtrl) {
if(event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
updateRows(bulkChangeCtrl.getUpdatedItems());
fireEvent(ureq, new QPoolEvent(QPoolEvent.BULK_CHANGE));
}
cmc.deactivate();
cleanUp();
......@@ -371,6 +372,11 @@ public class QuestionListController extends AbstractItemListController implement
} else if("next".equals(qce.getCommand())) {
doNext(ureq, qce.getItem());
}
} else if (event instanceof QPoolEvent) {
QPoolEvent qce = (QPoolEvent)event;
if(QPoolEvent.ITEM_DELETED.equals(qce.getCommand())) {
fireEvent(ureq, qce);
}
}
} else if(source == addController) {
if(event instanceof EntryChangedEvent) {
......@@ -610,6 +616,7 @@ public class QuestionListController extends AbstractItemListController implement
listenTo(cmc);
cmc.activate();
}
private void doExportToRepositoryEntry(UserRequest ureq, Long repoEntryKey) {
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(repoEntryKey, false);
if(re != null) {
......@@ -619,8 +626,8 @@ public class QuestionListController extends AbstractItemListController implement
}
private void doCreateCollection(UserRequest ureq, String name, List<QuestionItemShort> items) {
qpoolService.createCollection(getIdentity(), name, items);
fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CREATED));
QuestionItemCollection coll = qpoolService.createCollection(getIdentity(), name, items);
fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CREATED, coll.getKey()));
}
private void doChooseAuthoren(UserRequest ureq, List<QuestionItemShort> items) {
......@@ -700,7 +707,7 @@ public class QuestionListController extends AbstractItemListController implement
private void doRenameItemCollection(UserRequest ureq, String newName) {
itemCollection = qpoolService.renameCollection(itemCollection, newName);
fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CHANGED));
fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CHANGED, itemCollection.getKey()));
}
private void doConfirmDeleteSource(UserRequest ureq) {
......
......@@ -45,9 +45,11 @@ import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.Persistable;
import org.olat.core.id.Roles;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.util.nodes.INode;
import org.olat.core.util.resource.OresHelper;
import org.olat.core.util.tree.TreeHelper;
import org.olat.group.BusinessGroup;
......@@ -82,8 +84,7 @@ public class QuestionPoolMainEditorController extends BasicController implements
public static final OLATResourceable QITEM_MARKED = OresHelper.createOLATResourceableType("QItemMark");
private final MenuTree menuTree;
private GenericTreeNode sharesNode, myNode;
private GenericTreeNode sharesNode, myNode, myOwnNode;
private final Panel content;
private StackedController stackPanel;
......@@ -207,13 +208,18 @@ public class QuestionPoolMainEditorController extends BasicController implements
} else if(QPoolEvent.COLL_CREATED.equals(event.getCommand())
|| QPoolEvent.COLL_CHANGED.equals(event.getCommand())) {
buildMySubTreeModel(myNode);
Long collKey = ((QPoolEvent)event).getObjectKey();
GenericTreeNode nodeToSelect = findNodeByPersistableUserObject(myNode, collKey);
if(nodeToSelect != null) {
menuTree.setSelectedNode(nodeToSelect);
QuestionItemCollection coll = (QuestionItemCollection)nodeToSelect.getUserObject();
doSelectCollection(ureq, coll, nodeToSelect, null, null);
}
menuTree.setDirty(true);
} else if(QPoolEvent.COLL_DELETED.equals(event.getCommand())) {
buildMySubTreeModel(myNode);
menuTree.setDirty(true);
menuTree.setSelectedNode(myNode);
currentCtrl = null;
content.popContent();
menuTree.setSelectedNode(myOwnNode);
doSelectMyQuestions(ureq, null, null);
} else if(QPoolEvent.POOL_CREATED.equals(event.getCommand())
|| QPoolEvent.POOL_DELETED.equals(event.getCommand())) {
buildShareSubTreeModel(sharesNode);
......@@ -552,11 +558,11 @@ public class QuestionPoolMainEditorController extends BasicController implements
private void buildMySubTreeModel(GenericTreeNode parentNode) {
parentNode.removeAllChildren();
GenericTreeNode node = new GenericTreeNode(translate("menu.database.my"), "My");
node.setIconCssClass("o_sel_qpool_my_items");
parentNode.addChild(node);
myOwnNode = new GenericTreeNode(translate("menu.database.my"), "My");
myOwnNode.setIconCssClass("o_sel_qpool_my_items");
parentNode.addChild(myOwnNode);
node = new GenericTreeNode(translate("menu.database.favorit"), "Marked");
GenericTreeNode node = new GenericTreeNode(translate("menu.database.favorit"), "Marked");
node.setIconCssClass("o_sel_qpool_favorits");
parentNode.addChild(node);
......@@ -568,6 +574,28 @@ public class QuestionPoolMainEditorController extends BasicController implements
}
}
private GenericTreeNode findNodeByPersistableUserObject(GenericTreeNode parentNode, Long id) {
if(parentNode == null || id == null) {
return null;
}
for(int i=parentNode.getChildCount(); i-->0; ) {
INode node = parentNode.getChildAt(i);
if(node instanceof GenericTreeNode) {
GenericTreeNode treeNode = (GenericTreeNode)node;
Object userObj = treeNode.getUserObject();
if(userObj instanceof Persistable) {
Persistable obj = (Persistable)userObj;
if(id.equals(obj.getKey())) {
return treeNode;
}
}
}
}
return null;
}
private static class ControlledTreeNode extends GenericTreeNode {
private static final long serialVersionUID = 768640290449143804L;
private QuestionsController controller;
......
......@@ -176,6 +176,12 @@ public class QuestionsController extends BasicController implements Activateable
QuestionItemView item = se.getItem();
doUpdateDetails(ureq, item);
} else if(event instanceof QPoolEvent) {
if(QPoolEvent.BULK_CHANGE.equals(event.getCommand())) {
updateSelectAfterChange(ureq);
} else if(QPoolEvent.ITEM_DELETED.equals(event.getCommand())) {
postDelete(ureq);
stackPanel.popUpToRootController(ureq);
}
fireEvent(ureq, event);
}
} else if(source == confirmDeleteBox) {
......@@ -196,6 +202,16 @@ public class QuestionsController extends BasicController implements Activateable
super.event(ureq, source, event);
}
protected void updateSelectAfterChange(UserRequest ureq) {
QuestionItem item = previewCtrl.getItem();
Collection<Long> key = Collections.singletonList(item.getKey());
List<QuestionItemView> items = source.getItems(key);
if(items.size() > 0) {
QuestionItemView itemView = items.get(0);
doUpdateDetails(ureq, itemView);
}
}
protected void doSelect(UserRequest ureq, QuestionItem item, boolean editable) {
listCtrl.doSelect(ureq, item, editable);
}
......
......@@ -39,11 +39,25 @@ public class QPoolEvent extends MultiUserEvent {
public static final String COLL_CHANGED = "qpoll-coll-changed";
public static final String POOL_CREATED = "qpool-pool-created";
public static final String POOL_DELETED = "qpool-pool-deleted";
public static final String BULK_CHANGE = "qpool-bulk-change";
public static final String EDIT = "edit";
private Long objectKey;
public QPoolEvent(String cmd) {
super(cmd);
}
public QPoolEvent(String cmd, Long objectKey) {
super(cmd);
this.objectKey = objectKey;
}
public Long getObjectKey() {
return objectKey;
}
public void setObjectKey(Long objectKey) {
this.objectKey = objectKey;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment