This is an automated email from the ASF dual-hosted git repository. joergrade pushed a commit to branch ISIS-3171 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 021eed2391a2fb105514db4b5a6a5651ebcade1c Author: Jörg Rade <[email protected]> AuthorDate: Thu Feb 9 18:46:29 2023 +0100 ISIS-3171 table is shown, hidden/disabled/name not correctly set yet --- .../collection_layout_aggregation_diagram.adoc | 7 +++++-- .../kroviz/core/aggregator/CollectionAggregator.kt | 11 ++++++----- .../client/kroviz/core/model/CollectionDM.kt | 6 +++++- .../client/kroviz/core/model/CollectionLayout.kt | 19 ++++-------------- .../causeway/client/kroviz/core/model/ObjectDM.kt | 15 +++++++++++++- .../client/kroviz/core/model/ObjectLayout.kt | 12 ++++------- .../kroviz/core/model/PropertySpecification.kt | 4 ++++ .../client/kroviz/ui/builder/ColBuilder.kt | 2 ++ .../client/kroviz/ui/core/ColumnFactory.kt | 23 +++++++++++++--------- .../causeway/client/kroviz/ui/core/ViewManager.kt | 2 +- 10 files changed, 59 insertions(+), 42 deletions(-) diff --git a/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc index 365fb2890b..bbef7a319d 100644 --- a/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc +++ b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc @@ -64,12 +64,13 @@ together { } class ObjectDM <<(M,orange)DisplayModel>> #lightyellow { layout - collectionDmMap + collectionModelList data: Exposer readyToRender() } class ObjectLayout <<(L,orange)Layout>> #pink { grid + collectionLayoutList readyToRender() } ObjectAggregator --> ObjectDM @@ -86,19 +87,21 @@ together { isParentedCollection() } class CollectionDM <<(M,coral)DisplayModel>> #lightyellow { + id layout data[]: Exposer readyToRender() } class CollectionLayout <<(L,coral)Layout>> #pink{ numberOfColumns - propertySpecificationMap + propertySpecificationList readyToRender() } CollectionAggregator --> CollectionDM CollectionDM --> CollectionLayout } ObjectDM o-r-> CollectionDM +ObjectLayout o-> CollectionLayout ' references between Layout and TO classes CollectionLayout ..> TObject : handles diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt index 17aabcb0f7..e31da813c9 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt @@ -141,13 +141,14 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg } private fun handleCollection(collection: Collection) { - console.log("[CA_handleCollection]") if (isParentedCollection()) { - val cdm = getDisplayModel() - cdm.id = collection.id + //TODO is _id_ required in both CollectionDM and CollectionLayout? + val id = collection.id + getDisplayModel().id = id + getLayout().id = id // add displayModel to parent.displayModel - val parentDM = parent!!.getDisplayModel() - parentDM.collectionModelList.add(cdm) + val objectDM = parent!!.getDisplayModel() + objectDM.addCollectionModel(getDisplayModel()) } collection.links.forEach { if (it.relation() == Relation.DESCRIBED_BY) { diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt index 2f7aa90034..a1c236b0ac 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt @@ -33,7 +33,11 @@ class CollectionDM(override val title: String) : DisplayModelWithLayout() { private var rawData = observableListOf<TransferObject>() override fun readyToRender(): Boolean { - return (layout as CollectionLayout).readyToRender() + return getLayout().readyToRender() + } + + fun getLayout(): CollectionLayout { + return layout as CollectionLayout } override fun addData(obj: TransferObject, aggregator: AggregatorWithLayout?, referrer: String?) { diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt index 2f69d7148e..dba84dd14b 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt @@ -32,19 +32,12 @@ import org.apache.causeway.client.kroviz.to.TObject * - hidden : will the column be displayed or not */ class CollectionLayout : BaseLayout() { + var id = "" private var numberOfColumns = 0 - private val propertySpecificationList = mutableListOf<PropertySpecification>() + val propertySpecificationList = mutableListOf<PropertySpecification>() override fun readyToRender(): Boolean { - console.log("[CL_readyToRender]") - console.log(propertySpecificationList.size) - val isReady = isInitialized() && allPropertySpecificationsAreCreated() - if (isReady) { - propertySpecificationList.forEach { - console.log(it) - } - } - return isReady + return isInitialized() && allPropertySpecificationsAreCreated() } /** @@ -68,7 +61,7 @@ class CollectionLayout : BaseLayout() { } private fun allPropertySpecificationsAreCreated(): Boolean { - return (numberOfColumns == propertySpecificationList.size) + return numberOfColumns == propertySpecificationList.size } override fun addObjectProperty( @@ -98,8 +91,4 @@ class CollectionLayout : BaseLayout() { ps.amendWith(propertyDescription) } - fun getColumnDescriptions(): List<PropertySpecification> { - return propertySpecificationList - } - } \ No newline at end of file diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt index b0bfb49362..e8866bddad 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt @@ -39,20 +39,33 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() { dirty = value } + fun addCollectionModel(collectionModel: CollectionDM) { + val id = collectionModel.id + val foundModel = collectionModelList.firstOrNull() { + it.id == id + } + if (foundModel == null) { + collectionModelList.add(collectionModel) + } + } + override fun addLayout(lt: Layout) { TODO("Not yet implemented") } fun getCollectionDisplayModelFor(id: String): CollectionDM { + console.log("[ODM_getCollectionDisplayModelFor]") + console.log(id) + console.log(collectionModelList) return collectionModelList.find { it.id == id }!! } override fun readyToRender(): Boolean { - console.log("[ODM_readyToRender]") return when { data == null -> false isRendered -> false layout == null -> false + collectionModelList.size == 0 -> false else -> layout!!.readyToRender() //collectionsReadyToRender() } } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt index f2e85ee268..d5023d6cd3 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt @@ -32,17 +32,14 @@ import org.apache.causeway.client.kroviz.to.bs.RowBs class ObjectLayout : BaseLayout() { var grid: GridBs? = null - private val collectionLayoutMap = mutableMapOf<String, CollectionLayout>() + private val collectionLayoutList = mutableListOf< CollectionLayout>() override fun readyToRender(): Boolean { - console.log("[OL_readyToRender]") -// val o = js(arrayOf(collectionLayoutMap.values)) - console.log(collectionLayoutMap.keys) - var answer = when (grid) { + return when (grid) { null -> false else -> { var answer = true - collectionLayoutMap.values.forEach { + collectionLayoutList.forEach { if (!it.readyToRender()) { answer = false } @@ -50,7 +47,6 @@ class ObjectLayout : BaseLayout() { answer } } - return answer } override fun addObjectProperty( @@ -58,7 +54,7 @@ class ObjectLayout : BaseLayout() { aggregator: AggregatorWithLayout, referrer: String ) { - console.log("[OL_addObjectProperty]") + // console.log("[OL_addObjectProperty]") // TODO("Not yet implemented") } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt index 539d8fd979..1ae19ea398 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt @@ -41,6 +41,10 @@ class PropertySpecification(member: Member) { id = member.id name = member.id // can be changed later via property-description hidden = false // can be changed later via ... + //FIXME + if (name == "sources" || name == "description" || name == "logicalTypeName") { + hidden = true + } disabled = member.disabledReason.isNotEmpty() } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt index 6db3b9f247..95bd7caa9c 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt @@ -69,6 +69,8 @@ class ColBuilder : UiBuilder() { val id = it.id val objectDM = dsp.displayModel val cdm = objectDM.getCollectionDisplayModelFor(id) + console.log("[CB_create]") + console.log(cdm) val tblCpt = RoTable(cdm) val fsPanel = FieldsetPanel(legend = StringUtils.capitalize(cdm.title)).add(tblCpt) panel.add(fsPanel) diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt index 398d1bb8a8..c63b941b53 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt @@ -42,11 +42,11 @@ class ColumnFactory { } fun buildColumns(displayCollection: CollectionDM): List<ColumnDefinition<dynamic>> { - console.log("[CF_buildColumns]") val columns = mutableListOf<ColumnDefinition<Exposer>>() addColumnForObjectIcon(displayCollection, columns) addColumnsForProperties(displayCollection, columns) columns.add(columnForObjectMenu()) + console.log("[CF_buildColumns]") console.log(columns) return columns } @@ -103,18 +103,23 @@ class ColumnFactory { } private fun addColumnsForProperties( - displayCollection: CollectionDM, + collectionModel: CollectionDM, columns: MutableList<ColumnDefinition<Exposer>>, ) { - val cl = displayCollection.layout as CollectionLayout - val colDescList = cl.getColumnDescriptions() - for (cd in colDescList) { - if (!cd.hidden) { + console.log("[CF_addColumnsForProperties]") + val clo = collectionModel.getLayout() + val propSpecList = clo.propertySpecificationList + if (propSpecList.size == 0) { + throw IllegalStateException() + } + propSpecList.forEach { + console.log(it) + if (!it.hidden) { var colDef = ColumnDefinition<dynamic>( - title = cd.name, - field = cd.id, + title = it.name, + field = it.id, headerFilter = Editor.INPUT) - if (cd.id == "object") { + if (it.id == "object") { colDef = buildLink() } columns.add(colDef) diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt index 457fe0ae00..64a74f3c52 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt @@ -239,7 +239,7 @@ object ViewManager { return SessionManager.getEventStore() } - fun countDialogs(): Int { + private fun countDialogs(): Int { return popups.size + 1 }
