Project

General

Profile

Revision 2ef98d3e

ID2ef98d3ee5667951a9c7402fa6b963e949125d9d
Parent 1f016f08
Child b6b666d7

Added by Andreas Kohlbecker 4 months ago

fix #6869 ReferencePopupEditor: only admins and curation are allowed to edit advances fields, except for author team caches

View differences:

src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
224 224
    /**
225 225
     *
226 226
     */
227

  
228 227
    private void executeSuppliedCommands() {
229 228

  
230 229
        if(commandsExecuted){
src/main/java/eu/etaxonomy/cdm/vaadin/permission/RolesAndPermissions.java
24 24

  
25 25
    public static final Role ROLE_CURATION = new Role(UUID.fromString("642d9ea7-f18c-4ac3-b437-ed05ce5461c3"), "ROLE_CURATION");
26 26

  
27

  
28 27
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.reference;
10 10

  
11
import java.util.Arrays;
11 12
import java.util.Collection;
12 13
import java.util.EnumSet;
13 14
import java.util.HashMap;
......
28 29
import com.vaadin.ui.ListSelect;
29 30
import com.vaadin.ui.TextField;
30 31

  
32
import eu.etaxonomy.cdm.api.utility.RoleProber;
31 33
import eu.etaxonomy.cdm.model.agent.Institution;
32 34
import eu.etaxonomy.cdm.model.common.AnnotationType;
33 35
import eu.etaxonomy.cdm.model.reference.Reference;
34 36
import eu.etaxonomy.cdm.model.reference.ReferencePropertyDefinitions;
35 37
import eu.etaxonomy.cdm.model.reference.ReferencePropertyDefinitions.UnimplemetedCaseException;
36 38
import eu.etaxonomy.cdm.model.reference.ReferenceType;
39
import eu.etaxonomy.cdm.service.UserHelperAccess;
37 40
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix;
38 41
import eu.etaxonomy.cdm.vaadin.component.common.FilterableAnnotationsField;
39 42
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
......
41 44
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction;
42 45
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
43 46
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
47
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
44 48
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
45 49
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
46 50
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator;
......
391 395
        }
392 396
    }
393 397

  
398

  
399
    @Override
400
    public void setAdvancedMode(boolean isAdvancedMode) {
401
        boolean isCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
402
        boolean isAdmin = UserHelperAccess.userHelper().userIsAdmin();
403

  
404
        boolean canEditAllCaches = isAdmin || isCurator;
405
        super.setAdvancedMode(isAdvancedMode);
406
        if(!canEditAllCaches){
407
            advancedModeComponents.forEach(c -> c.setReadOnly(true));
408
            Arrays.asList(authorshipField.getCachFields()).forEach(c -> c.setReadOnly(false));
409
        }
410
    }
411

  
412

  
394 413
    /**
395 414
     * {@inheritDoc}
396 415
     */
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
127 127

  
128 128
    private boolean isAdvancedMode = false;
129 129

  
130
    private List<Component> advancedModeComponents = new ArrayList<>();
130
    protected List<Component> advancedModeComponents = new ArrayList<>();
131 131

  
132 132
    private Button advancedModeButton;
133 133

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)