Skip to content

Commit

Permalink
add readonly option to HUEditorRowAttributesProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 3, 2017
1 parent 5a44224 commit b1dfee9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import de.metas.ui.web.window.datatypes.DocumentId;
import de.metas.ui.web.window.datatypes.DocumentPath;
import de.metas.ui.web.window.datatypes.DocumentType;
import lombok.Builder;
import lombok.Value;

/*
Expand All @@ -47,11 +48,8 @@

public class HUEditorRowAttributesProvider implements IViewRowAttributesProvider
{
public static final HUEditorRowAttributesProvider newInstance()
{
return new HUEditorRowAttributesProvider();
}

private final boolean readonly;

private final ExtendedMemorizingSupplier<IAttributeStorageFactory> _attributeStorageFactory = ExtendedMemorizingSupplier.of(() -> createAttributeStorageFactory());
private final ConcurrentHashMap<ViewRowAttributesKey, HUEditorRowAttributes> rowAttributesByKey = new ConcurrentHashMap<>();

Expand All @@ -62,11 +60,17 @@ private static final class ViewRowAttributesKey
private DocumentId huId;
}

private HUEditorRowAttributesProvider()
@Builder
private HUEditorRowAttributesProvider(final boolean readonly)
{
super();
this.readonly = readonly;
}


private boolean isReadonly()
{
return readonly;
}

public DocumentId createAttributeKey(final int huId)
{
return DocumentId.of(huId);
Expand Down Expand Up @@ -95,9 +99,10 @@ private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key
final DocumentId huEditorRowId = key.getHuEditorRowId();
final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);

final boolean readonly = !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus()); // readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
final boolean rowAttributesReadonly = isReadonly() // readonly if the provider shall provide readonly attributes
|| !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus()); // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314

return new HUEditorRowAttributes(documentPath, attributesStorage, readonly);
return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}

private IAttributeStorageFactory getAttributeStorageFactory()
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/de/metas/ui/web/handlingunits/HUEditorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ public static HUEditorView cast(final IView view)
private HUEditorView(final Builder builder)
{
parentViewId = builder.getParentViewId();

this.huAttributesProvider = HUEditorRowAttributesProvider.newInstance();

this.huAttributesProvider = HUEditorRowAttributesProvider.builder()
//.readonly(isHighVolume)
.build();

final HUEditorViewRepository huEditorRepo = HUEditorViewRepository.builder()
.windowId(builder.getWindowId())
.referencingTableName(builder.getReferencingTableName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ public PPOrderLinesLoader(final WindowId windowId, final ASIViewRowAttributesPro
{
this.windowId = windowId;

huAttributesProvider = HUEditorRowAttributesProvider.newInstance();
huAttributesProvider = HUEditorRowAttributesProvider.builder()
.readonly(false)
.build();

huEditorRepo = HUEditorViewRepository.builder()
.windowId(windowId)
.referencingTableName(I_PP_Order.Table_Name)
Expand Down

0 comments on commit b1dfee9

Please sign in to comment.