Project

General

Profile

« Previous | Next » 

Revision adad0cac

Added by Andreas Kohlbecker over 6 years ago

fix #7343 addind expanable field for the nomenclaturalTitle of Person

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java
17 17
import com.vaadin.data.Validator.InvalidValueException;
18 18
import com.vaadin.data.fieldgroup.BeanFieldGroup;
19 19
import com.vaadin.data.fieldgroup.FieldGroup;
20
import com.vaadin.server.FontAwesome;
20 21
import com.vaadin.ui.Button;
21 22
import com.vaadin.ui.Component;
22 23
import com.vaadin.ui.CssLayout;
......
70 71
    private CssLayout root = new CssLayout();
71 72
    private CssLayout selectOrNewContainer = new CssLayout();
72 73

  
73
    private TextField cacheField = new TextFieldNFix();
74
    private TextField titleCacheField = new TextFieldNFix();
75
    private TextField nomenclaturalTitleField = new TextFieldNFix();
76
    private Button nomenclaturalTitleButton = new Button();
74 77
    private CssLayout detailsContainer = new CssLayout();
75 78
    private TextField initialsField = new TextFieldNFix();
76 79
    private TextField firstNameField = new TextFieldNFix();
......
82 85
    private boolean onCommit = false;
83 86

  
84 87

  
88

  
85 89
    /**
86 90
     * @param caption
87 91
     */
......
116 120
        });
117 121

  
118 122
        // edit person
119
        addStyledComponent(cacheField);
123
        addStyledComponent(titleCacheField);
120 124
        addStyledComponents(initialsField);
121 125
        addStyledComponent(firstNameField);
122 126
        addStyledComponent(lastNameField);
123 127
        addStyledComponent(prefixField);
124 128
        addStyledComponent(suffixField);
125 129
        addStyledComponent(unlockSwitch);
130
        addStyledComponent(nomenclaturalTitleField);
131
        addStyledComponent(nomenclaturalTitleButton);
126 132

  
127 133
        addSizedComponent(root);
128 134
    }
......
159 165
        selectOrNewContainer.setWidth(100, Unit.PERCENTAGE);
160 166
        personSelect.setWidthUndefined();
161 167

  
162
        root.addComponent(cacheField);
168
        root.addComponent(titleCacheField);
163 169
        root.addComponent(unlockSwitch);
164 170
        root.addComponent(selectOrNewContainer);
165 171

  
166
        cacheField.setWidth(100, Unit.PERCENTAGE);
172
        titleCacheField.setWidth(100, Unit.PERCENTAGE);
167 173

  
168 174
        prefixField.setWidth(baseWidth, Unit.PERCENTAGE);
169 175
        prefixField.setInputPrompt("Prefix");
......
172 178
        initialsField.setInputPrompt("Initials");
173 179

  
174 180
        firstNameField.setWidth(baseWidth * 3, Unit.PERCENTAGE);
175
        firstNameField.setInputPrompt("Family name");
181
        firstNameField.setInputPrompt("Other/given names");
176 182

  
177 183
        lastNameField.setWidth(baseWidth * 3, Unit.PERCENTAGE);
178
        lastNameField.setInputPrompt("Other/given names");
184
        lastNameField.setInputPrompt("Family name");
179 185

  
180 186
        suffixField.setWidth(baseWidth, Unit.PERCENTAGE);
181 187
        suffixField.setInputPrompt("Suffix");
......
188 194
        detailsContainer.addComponent(suffixField);
189 195
        root.addComponent(detailsContainer);
190 196

  
197
        nomenclaturalTitleButton.setHeight(22, Unit.PIXELS);
198
        nomenclaturalTitleButton.setDescription("Show the nomenclatural title cache.");
199
        nomenclaturalTitleButton.addClickListener( e -> {
200
            nomenclaturalTitleField.setVisible(!nomenclaturalTitleField.isVisible());
201
            nomenclaturalTitleButtonChooseIcon();
202
            if(nomenclaturalTitleField.isVisible()){
203
                nomenclaturalTitleField.focus();
204
            }
205
        });
206
        // nomenclaturalTitleField.setCaption("Nomenclatural title");
207
        nomenclaturalTitleField.setWidth(100, Unit.PERCENTAGE);
208

  
209
        root.addComponent(nomenclaturalTitleField);
210
        root.addComponent(nomenclaturalTitleButton);
211

  
191 212
        unlockSwitch.addValueChangeListener(e -> {
192 213
            if(refreshMode()){
193 214
                switch (currentMode) {
194 215
                    case CACHE_MODE:
195
                        cacheField.focus();
216
                        titleCacheField.focus();
196 217
                        break;
197 218
                    case DETAILS_MODE:
198 219
                        firstNameField.focus();
......
210 231
        addDefaultStyles();
211 232
        setMode(Mode.DETAILS_MODE);
212 233

  
213
        fieldGroup.bind(cacheField, "titleCache");
234
        fieldGroup.bind(titleCacheField, "titleCache");
214 235
        fieldGroup.bind(prefixField, "prefix");
215 236
        fieldGroup.bind(initialsField, "initials");
216 237
        fieldGroup.bind(firstNameField, "firstname");
217 238
        fieldGroup.bind(lastNameField, "lastname");
218 239
        fieldGroup.bind(suffixField, "suffix");
219 240
        fieldGroup.bind(unlockSwitch, "protectedTitleCache");
241
        fieldGroup.bind(nomenclaturalTitleField, "nomenclaturalTitle");
220 242
        fieldGroup.setBuffered(false);
221 243

  
222 244
        updateVisibilities(getValue());
......
224 246
        return root;
225 247
    }
226 248

  
249
    /**
250
     *
251
     */
252
    protected void nomenclaturalTitleButtonChooseIcon() {
253
        nomenclaturalTitleButton.setIcon(nomenclaturalTitleField.isVisible() ? FontAwesome.ANGLE_UP : FontAwesome.ELLIPSIS_H);
254
    }
255

  
227 256
    /**
228 257
     *
229 258
     * @return true if the mode has changed
......
245 274
    @Override
246 275
    public void setValue(Person person){
247 276
        super.setValue(person);
277
//        PersonFieldAccess personWrapper = new PersonFieldAccess(person);
278
//        super.setValue(personWrapper);
248 279
        personSelect.setValue(person);
249 280
    }
250 281

  
......
269 300

  
270 301
        detailsContainer.setVisible(person != null);
271 302
        unlockSwitch.setVisible(person != null);
272
        cacheField.setVisible(person != null);
303
        titleCacheField.setVisible(person != null);
304
        nomenclaturalTitleField.setVisible(nomenclaturalTitleField.getValue().equals(titleCacheField.getValue()));
305
        nomenclaturalTitleButtonChooseIcon();
273 306

  
274 307
    }
275 308

  
276 309
    @Override
277 310
    protected void addDefaultStyles(){
278
        cacheField.addStyleName("cache-field");
311
        titleCacheField.addStyleName("cache-field");
279 312
        detailsContainer.addStyleName("details-fields");
280 313
        unlockSwitch.addStyleName(Switch.DOM_STYLE);
314
        nomenclaturalTitleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED + " center-h");
281 315
    }
282 316

  
283 317
    /**
......
302 336
            Person value = getValue();
303 337
            if(value != null && value.getId() == 0){
304 338
                // only if the entity is unsaved!
305
                ignoreFields.add(cacheField);
306
                cacheField.setValue(null);
339
                ignoreFields.add(titleCacheField);
340
                titleCacheField.setValue(null);
307 341
            }
308 342
        }
309 343
        return ignoreFields;
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
119 119
       line-height: 50px;
120 120
     }
121 121
   }
122
   
123
   .v-button-center-h {
124
    // requires width to be defined 
125
    display: block;
126
    margin: 0 auto;
127
   }
122 128

  
123 129
   .v-label .caption {
124 130
       font-size: $v-font-size--small;

Also available in: Unified diff