Changeset 5540


Ignore:
Timestamp:
08/08/14 08:26:55 (10 years ago)
Author:
Twan Goosen
Message:

Enabled 'edit' option with confirmation dialogue for published collections (works for private collections and owner) and allowed access to edit view for non-private
Refs #600

Location:
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/Application.properties

    r1019 r5540  
    2020collections.deleteconfirm: Do you really want to delete "${name}"?\nThis \
    2121  operation is permanent and cannot be undone.
     22collections.editpublishedconfirm: Do you really want to edit the PUBLISHED \
     23collection "${name}"?\n\
     24  Any changes will be made public immediately after editing and cannot be \
     25  undone. Be aware that other users may not expect a published collection to \
     26  change!
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/pages/BrowseEditableCollectionsPanel.html

    r5501 r5540  
    99  <div style="display: none" wicket:id="publishCollectionDialog"></div>
    1010  <div style="display: none" wicket:id="deleteCollectionDialog"></div>
     11  <div style="display: none" wicket:id="editPublishedCollectionDialog"></div>
    1112  <div wicket:id="collectionsTable"></div>
    1213</wicket:panel>
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/pages/BrowseEditableCollectionsPanel.java

    r5501 r5540  
    9090                                            if (vc.isDeleted()) {
    9191                                                detailsItem.setVisible(false).setEnabled(false);
     92                                                editItem.setVisible(false).setEnabled(false);
    9293                                            }
    9394                                            if (!vc.isPrivate()) {
    94                                                 editItem.setVisible(false).setEnabled(false);
    9595                                                publishItem.setVisible(false).setEnabled(false);
    9696                                                deleteItem.setVisible(false).setEnabled(false);
     
    144144            if (vc.isDeleted()) {
    145145                detailsLink.setVisible(false).setEnabled(false);
     146                editLink.setVisible(false).setEnabled(false);
    146147            }
    147148            if (!vc.isPrivate()) {
    148                 editLink.setVisible(false).setEnabled(false);
    149149                publishLink.setVisible(false).setEnabled(false);
    150150                deleteLink.setVisible(false).setEnabled(false);
     
    212212    } // class BrowsePrivateCollectionsPage.PublishCollectionDialog
    213213
     214    private final class EditPublishedCollectionDialog extends ConfirmationDialog {
     215
     216        private long vcId;
     217
     218        public EditPublishedCollectionDialog(String id,
     219                final Component updateComponenet) {
     220            super(id, updateComponenet);
     221            setInitialWidth(400);
     222        }
     223
     224        @Override
     225        public void onConfirm(AjaxRequestTarget target) {
     226            setResponsePage(EditVirtualCollectionPage.class, new PageParameters(Collections.singletonMap("id", vcId)));
     227        }
     228
     229        public void showDialogue(AjaxRequestTarget target, VirtualCollection vc) {
     230            this.vcId = vc.getId();
     231            super.show(target,
     232                    new StringResourceModel("collections.editpublishedconfirm",
     233                            new VolatileEntityModel<>(vc)));
     234        }
     235    }
     236
    214237    private final PublishCollectionDialog publishDialog;
    215238    private final DeleteCollectionDialog deleteDialog;
     239    private final EditPublishedCollectionDialog editPublishedDialog;
    216240
    217241    /**
    218      * 
     242     *
    219243     * @param id panel id
    220244     * @param provider provider for collections that should be shown
     
    238262        add(table);
    239263
    240         publishDialog = new PublishCollectionDialog("publishCollectionDialog",
    241                 table);
     264        publishDialog = new PublishCollectionDialog("publishCollectionDialog", table);
    242265        add(publishDialog);
    243         deleteDialog = new DeleteCollectionDialog("deleteCollectionDialog",
    244                 table);
     266       
     267        deleteDialog = new DeleteCollectionDialog("deleteCollectionDialog", table);
    245268        add(deleteDialog);
    246     }
    247 
    248     private void doEdit(AjaxRequestTarget target,
    249             VirtualCollection vc) {
    250         setResponsePage(EditVirtualCollectionPage.class, new PageParameters(Collections.singletonMap("id", vc.getId())));
     269       
     270        editPublishedDialog = new EditPublishedCollectionDialog("editPublishedCollectionDialog", table);
     271        add(editPublishedDialog);
     272
     273    }
     274
     275    private void doEdit(AjaxRequestTarget target, VirtualCollection vc) {
     276        if (vc.isPublic()) {
     277            // ask for confirmation when trying to edit a published collection
     278            editPublishedDialog.showDialogue(target, vc);
     279        } else {
     280            setResponsePage(EditVirtualCollectionPage.class, new PageParameters(Collections.singletonMap("id", vc.getId())));
     281        }
    251282    }
    252283
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/pages/EditVirtualCollectionPage.java

    r5504 r5540  
    4040        // do not allow editing of VC's that are non-private or owned
    4141        // by someone else! (except for admin)
    42         if (!isUserAdmin() &&
    43                 (vc.getState() != State.PRIVATE
     42        if (!isUserAdmin()
     43                && ( //only allow editing of private & public
     44                !(vc.getState() == State.PRIVATE || vc.getState() == State.PUBLIC)
     45                // only allow editing by the owner
    4446                || !vc.getOwner().equalsPrincipal(getUser()))) {
    4547            logger.warn("User {} attempts to edit virtual collection {} with state {} owned by {}", new Object[]{getUser().getName(), vc.getId(), vc.getState(), vc.getOwner().getName()});
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/model/User.java

    r5446 r5540  
    102102        if (principal == null) {
    103103            throw new NullPointerException("principal == null");
    104         }
     104    }
    105105        return name.equals(principal.getName());
    106106    }
Note: See TracChangeset for help on using the changeset viewer.