use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class WindowRestController method deleteRootDocumentsList.
@DeleteMapping("/{windowId}")
public List<JSONDocument> deleteRootDocumentsList(//
@PathVariable("windowId") final String windowIdStr, //
@RequestParam(name = "ids") @ApiParam("comma separated documentIds") final String idsListStr) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final List<DocumentPath> documentPaths = DocumentPath.rootDocumentPathsList(windowId, idsListStr);
if (documentPaths.isEmpty()) {
throw new IllegalArgumentException("No ids provided");
}
return deleteDocuments(documentPaths);
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class WindowRestController method discardChanges.
@PostMapping("/{windowId}/{documentId}/discardChanges")
public void discardChanges(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr) {
userSession.assertLoggedIn();
final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), DocumentId.of(documentIdStr));
documentCollection.invalidateRootDocument(documentPath);
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class WindowRestController method deleteRootDocument.
@DeleteMapping("/{windowId}/{documentId}")
public List<JSONDocument> deleteRootDocument(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
return deleteDocuments(ImmutableList.of(documentPath));
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getDocumentFieldDropdown.
@GetMapping("/{windowId}/{documentId}/field/{fieldName}/dropdown")
public JSONLookupValuesList getDocumentFieldDropdown(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId, //
@PathVariable("fieldName") final String fieldName) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
return getDocumentFieldDropdown(documentPath, fieldName);
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class DocumentPermissionsHelper method checkCanEdit.
private static String checkCanEdit(@NonNull final Document document, @NonNull final IUserRolePermissions permissions) {
// In case document type is not Window, return OK because we cannot validate
final DocumentPath documentPath = document.getDocumentPath();
if (documentPath.getDocumentType() != DocumentType.Window) {
// OK
return null;
}
// Check if we have window write permission
final AdWindowId adWindowId = documentPath.getWindowId().toAdWindowIdOrNull();
if (adWindowId != null && !permissions.checkWindowPermission(adWindowId).hasWriteAccess()) {
return "no window edit permission";
}
final int adTableId = getAdTableId(document);
if (adTableId <= 0) {
// not table based => OK
return null;
}
final int recordId = getRecordId(document);
final ClientId adClientId = document.getClientId();
final OrgId adOrgId = document.getOrgId();
if (adOrgId == null) {
// the user cleared the field; field is flagged as mandatory; until user set the field, don't make a fuss.
return null;
}
return permissions.checkCanUpdate(adClientId, adOrgId, adTableId, recordId);
}
Aggregations