Project

General

Profile

« Previous | Next » 

Revision ca768ad3

Added by Andreas Kohlbecker almost 4 years ago

ref #7322 hiding addTypeButton when user is not permitted to update the registration

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemNameAndTypeButtons.java
21 21
import com.vaadin.ui.Link;
22 22
import com.vaadin.ui.themes.ValoTheme;
23 23

  
24
import eu.etaxonomy.cdm.model.name.Registration;
24 25
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
25 26
import eu.etaxonomy.cdm.model.name.TaxonName;
26 27
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
......
90 91
                addComponent(nameLabel);
91 92
            }
92 93
        }
94
        boolean userHasAddPermission = UserHelper.fromSession().userHasPermission(Registration.class, regDto.getId(), CRUD.UPDATE);
93 95
        if(regDto.getOrderdTypeDesignationWorkingSets() != null){
94 96
            for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) {
95 97
                TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef);
......
97 99
                String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
98 100
                Button tdButton = new Button(buttonLabel + ":");
99 101
                tdButton.setDescription("Edit the type designation working set");
100
                boolean userHasPermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE);
101
                tdButton.setReadOnly(isRegistrationLocked || !userHasPermission);
102
                boolean userHasUpdatePermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE, CRUD.DELETE);
103
                tdButton.setReadOnly(isRegistrationLocked || !userHasUpdatePermission);
102 104
                addComponent(tdButton);
103 105

  
104 106
                PermissionDebugUtils.addGainPerEntityPermissionButton(this, SpecimenOrObservationBase.class,
......
126 128
            }
127 129
        }
128 130
        addTypeDesignationButton = new Button(FontAwesome.PLUS);
129
        addTypeDesignationButton.setDescription("Add a new type designation workingset");
130
        addTypeDesignationButton.setVisible(!isRegistrationLocked);
131
        addTypeDesignationButton.setDescription("Add a new type designation workingset.");
132
        addTypeDesignationButton.setVisible(!isRegistrationLocked && userHasAddPermission);
131 133
        addComponent(addTypeDesignationButton);
132 134

  
133 135
        //TODO make responsive and use specificIdentifier in case the space gets too narrow

Also available in: Unified diff