Skip to content

Commit 48d1898

Browse files
committed
feat(vue-model-api): let root nodes of readonly bindings be readonly
1 parent 035cb2d commit 48d1898

9 files changed

Lines changed: 831 additions & 474 deletions

File tree

model-api/src/jsMain/kotlin/org/modelix/model/api/NodeAdapterJS.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ class NodeAdapterJS(val node: INode) : INodeJS_ {
113113
}
114114

115115
override fun setReferenceTargetNode(role: ReferenceRole, target: INodeJS?) {
116-
val unwrappedTarget = if (target == null) null else (target as NodeAdapterJS).node
117-
node.asWritableNode().setReferenceTarget(IReferenceLinkReference.fromRoleOrString(role), unwrappedTarget?.asWritableNode())
116+
if (target is NodeAdapterJS) {
117+
node.asWritableNode().setReferenceTarget(IReferenceLinkReference.fromRoleOrString(role), target.node.asWritableNode())
118+
} else {
119+
val targetRef = target?.getReference()
120+
setReferenceTargetRef(role, targetRef)
121+
}
118122
}
119123

120124
override fun setReferenceTargetRef(role: ReferenceRole, target: INodeReferenceJS?) {

model-client/src/jsMain/kotlin/org/modelix/model/client2/ClientJS.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ sealed class IdSchemeJS() {
9494
}
9595

9696
@JsExport
97-
data class VersionInformationWithModelTree(val version: VersionInformationJS, val tree: MutableModelTreeJs)
97+
data class VersionInformationWithModelTree(
98+
/**
99+
* The version information.
100+
*/
101+
val version: VersionInformationJS,
102+
/**
103+
* The model tree associated with the version.
104+
*/
105+
val tree: MutableModelTreeJs,
106+
)
98107

99108
/**
100109
* JS-API for [ModelClientV2].
@@ -104,6 +113,7 @@ data class VersionInformationWithModelTree(val version: VersionInformationJS, va
104113
* See https://issues.modelix.org/issue/MODELIX-962
105114
*/
106115
@JsExport
116+
@Suppress("TooManyFunctions")
107117
interface ClientJS {
108118

109119
/**
@@ -211,10 +221,14 @@ data class ReplicatedModelParameters(
211221
val repositoryId: String,
212222
val branchId: String? = null,
213223
val idScheme: IdSchemeJS,
224+
val readonly: Boolean = false,
214225
val versionHash: String? = null,
215226
) {
216227
init {
217228
require((branchId != null) xor (versionHash != null)) { "Exactly one of branchId or versionHash must be provided" }
229+
if (versionHash != null) {
230+
require(readonly) { "versionHash requires readonly=true" }
231+
}
218232
}
219233
}
220234

0 commit comments

Comments
 (0)