Revision f173032b
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java | ||
---|---|---|
255 | 255 |
} |
256 | 256 |
} |
257 | 257 |
|
258 |
private void checkUserPermissions(TeamOrPersonBase<?> newValue) { |
|
259 |
boolean userCanEdit = UserHelper.fromSession().userHasPermission(newValue, "DELETE", "UPDATE"); |
|
260 |
setEnabled(userCanEdit); |
|
261 |
personsListEditor.setEnabled(userCanEdit); |
|
262 |
} |
|
258 |
// private void checkUserPermissions(TeamOrPersonBase<?> newValue) {
|
|
259 |
// boolean userCanEdit = UserHelper.fromSession().userHasPermission(newValue, "DELETE", "UPDATE");
|
|
260 |
// setEnabled(userCanEdit);
|
|
261 |
// personsListEditor.setEnabled(userCanEdit);
|
|
262 |
// }
|
|
263 | 263 |
|
264 | 264 |
/** |
265 | 265 |
* {@inheritDoc} |
... | ... | |
298 | 298 |
//need to commit the subfields propagation through the fielGroups is not enough |
299 | 299 |
personField.commit(); |
300 | 300 |
personsListEditor.commit(); |
301 |
if(!getState(false).readOnly && getPropertyDataSource().isReadOnly()){ |
|
302 |
// the TeamOrPersonBase Editor (remove, addPerson, addTeam) is not readonly |
|
303 |
// thus removing the TeamOrPerson is allowed. In case the datasource is readonly |
|
304 |
// due to missing user grants for the TeamOrPerson it must be set to readWrite to |
|
305 |
// make it possible to change the property of the parent |
|
306 |
getPropertyDataSource().setReadOnly(false); |
|
307 |
} |
|
308 |
|
|
301 | 309 |
super.commit(); |
302 | 310 |
|
311 |
if(hasNullContent()){ |
|
312 |
getPropertyDataSource().setValue(null); |
|
313 |
setValue(null); |
|
314 |
} |
|
315 |
|
|
303 | 316 |
TeamOrPersonBase<?> bean = getValue(); |
304 | 317 |
if(bean != null && bean instanceof Team){ |
305 |
|
|
306 | 318 |
boolean isUnsaved = bean.getId() == 0; |
307 | 319 |
if(isUnsaved){ |
308 | 320 |
UserHelper.fromSession().createAuthorityForCurrentUser(bean, EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null); |
309 | 321 |
} |
310 | 322 |
} |
311 |
|
|
312 |
if(hasNullContent()){ |
|
313 |
if(!getState(false).readOnly && getPropertyDataSource().isReadOnly()){ |
|
314 |
// the TeamOrPersonBase Editor (remove, addPerson, addTeam) is not readonly |
|
315 |
// thus removing the TeamOrPerson is allowed. In case the datasource is readonly |
|
316 |
// due to missing user grants for the TeamOrPerson it must be set to readWrite to |
|
317 |
// before setting to null |
|
318 |
getPropertyDataSource().setReadOnly(false); |
|
319 |
} |
|
320 |
getPropertyDataSource().setValue(null); |
|
321 |
setValue(null); |
|
322 |
|
|
323 |
|
|
324 |
} |
|
325 | 323 |
} |
326 | 324 |
|
327 | 325 |
/** |
Also available in: Unified diff
ref #7366 disabling readonly during commmit when TaxonOrPersonField-Editor is write enabled