dmx-api 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/package.json +5 -2
- package/src/index.js +1 -1
- package/src/model.js +31 -17
- package/src/type-cache.js +7 -11
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dmx-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "API and utilities for DMX 5 based frontends",
|
|
5
5
|
"author": "Jörg Richter <jri@dmx.berlin>",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/dmx-systems/dmx-api.git"
|
|
10
|
+
"url": "git+https://github.com/dmx-systems/dmx-api.git"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"axios": "0.18.1",
|
|
14
14
|
"clone": "2.1.2",
|
|
15
15
|
"debounce": "1.2.0",
|
|
16
16
|
"font-awesome": "4.7.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"vue": "3.x"
|
|
17
20
|
}
|
|
18
21
|
}
|
package/src/index.js
CHANGED
package/src/model.js
CHANGED
|
@@ -2,7 +2,6 @@ import rpc from './rpc'
|
|
|
2
2
|
import typeCache from './type-cache'
|
|
3
3
|
import permCache from './permission-cache'
|
|
4
4
|
import utils from './utils'
|
|
5
|
-
import Vue from 'vue'
|
|
6
5
|
|
|
7
6
|
// TODO: inject or factor out
|
|
8
7
|
const DEFAULT_TOPIC_ICON = '\uf111' // fa-circle
|
|
@@ -734,6 +733,9 @@ class Topicmap extends Topic {
|
|
|
734
733
|
this._assocs = utils.mapById(utils.instantiateMany(topicmap.assocs, ViewAssoc)) // map: ID -> dmx.ViewAssoc
|
|
735
734
|
}
|
|
736
735
|
|
|
736
|
+
/**
|
|
737
|
+
* @param id Number or String
|
|
738
|
+
*/
|
|
737
739
|
getTopic (id) {
|
|
738
740
|
const topic = this.getTopicIfExists(id)
|
|
739
741
|
if (!topic) {
|
|
@@ -742,6 +744,9 @@ class Topicmap extends Topic {
|
|
|
742
744
|
return topic
|
|
743
745
|
}
|
|
744
746
|
|
|
747
|
+
/**
|
|
748
|
+
* @param id Number or String
|
|
749
|
+
*/
|
|
745
750
|
getAssoc (id) {
|
|
746
751
|
const assoc = this.getAssocIfExists(id)
|
|
747
752
|
if (!assoc) {
|
|
@@ -761,26 +766,44 @@ class Topicmap extends Topic {
|
|
|
761
766
|
return o
|
|
762
767
|
}
|
|
763
768
|
|
|
769
|
+
/**
|
|
770
|
+
* @param id Number or String
|
|
771
|
+
*/
|
|
764
772
|
getTopicIfExists (id) {
|
|
765
773
|
return this._topics[id]
|
|
766
774
|
}
|
|
767
775
|
|
|
776
|
+
/**
|
|
777
|
+
* @param id Number or String
|
|
778
|
+
*/
|
|
768
779
|
getAssocIfExists (id) {
|
|
769
780
|
return this._assocs[id]
|
|
770
781
|
}
|
|
771
782
|
|
|
783
|
+
/**
|
|
784
|
+
* @param id Number or String
|
|
785
|
+
*/
|
|
772
786
|
hasTopic (id) {
|
|
773
787
|
return this.getTopicIfExists(id)
|
|
774
788
|
}
|
|
775
789
|
|
|
790
|
+
/**
|
|
791
|
+
* @param id Number or String
|
|
792
|
+
*/
|
|
776
793
|
hasAssoc (id) {
|
|
777
794
|
return this.getAssocIfExists(id)
|
|
778
795
|
}
|
|
779
796
|
|
|
797
|
+
/**
|
|
798
|
+
* @param id Number or String
|
|
799
|
+
*/
|
|
780
800
|
hasObject (id) {
|
|
781
801
|
return this.hasTopic(id) || this.hasAssoc(id)
|
|
782
802
|
}
|
|
783
803
|
|
|
804
|
+
/**
|
|
805
|
+
* @param id Number or String
|
|
806
|
+
*/
|
|
784
807
|
hasVisibleObject (id) {
|
|
785
808
|
const o = this.getTopicIfExists(id) || this.getAssocIfExists(id)
|
|
786
809
|
return o && o.isVisible()
|
|
@@ -831,8 +854,7 @@ class Topicmap extends Topic {
|
|
|
831
854
|
if (!(topic instanceof ViewTopic)) {
|
|
832
855
|
throw Error(`addTopic() expects ViewTopic, got ${topic.constructor.name}`)
|
|
833
856
|
}
|
|
834
|
-
|
|
835
|
-
Vue.set(this._topics, topic.id, topic)
|
|
857
|
+
this._topics[topic.id] = topic
|
|
836
858
|
}
|
|
837
859
|
|
|
838
860
|
/**
|
|
@@ -845,8 +867,7 @@ class Topicmap extends Topic {
|
|
|
845
867
|
if (!(assoc instanceof ViewAssoc)) {
|
|
846
868
|
throw Error(`addAssoc() expects ViewAssoc, got ${assoc.constructor.name}`)
|
|
847
869
|
}
|
|
848
|
-
|
|
849
|
-
Vue.set(this._assocs, assoc.id, assoc)
|
|
870
|
+
this._assocs[assoc.id] = assoc
|
|
850
871
|
}
|
|
851
872
|
|
|
852
873
|
/**
|
|
@@ -919,11 +940,8 @@ class Topicmap extends Topic {
|
|
|
919
940
|
|
|
920
941
|
updateTopic (topic) {
|
|
921
942
|
if (this.id === topic.id) {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
'dmx.base.url#dmx.topicmaps.background_image',
|
|
925
|
-
topic.children['dmx.base.url#dmx.topicmaps.background_image']
|
|
926
|
-
)
|
|
943
|
+
const uri = 'dmx.base.url#dmx.topicmaps.background_image'
|
|
944
|
+
this.children[uri] = topic.children[uri]
|
|
927
945
|
}
|
|
928
946
|
}
|
|
929
947
|
|
|
@@ -934,16 +952,14 @@ class Topicmap extends Topic {
|
|
|
934
952
|
* Note: if the topic is not in this topicmap nothing is performed.
|
|
935
953
|
*/
|
|
936
954
|
removeTopic (id) {
|
|
937
|
-
|
|
938
|
-
Vue.delete(this._topics, id)
|
|
955
|
+
delete this._topics[id]
|
|
939
956
|
}
|
|
940
957
|
|
|
941
958
|
/**
|
|
942
959
|
* Note: if the assoc is not in this topicmap nothing is performed.
|
|
943
960
|
*/
|
|
944
961
|
removeAssoc (id) {
|
|
945
|
-
|
|
946
|
-
Vue.delete(this._assocs, id)
|
|
962
|
+
delete this._assocs[id]
|
|
947
963
|
}
|
|
948
964
|
|
|
949
965
|
// Associations
|
|
@@ -1042,9 +1058,7 @@ const viewPropsMixin = Base => class extends Base {
|
|
|
1042
1058
|
}
|
|
1043
1059
|
|
|
1044
1060
|
setViewProp (propUri, value) {
|
|
1045
|
-
|
|
1046
|
-
// Test it with topics/assocs which don't have a 'dmx.topicmaps.pinned' setting yet. ### FIXDOC
|
|
1047
|
-
Vue.set(this.viewProps, propUri, value)
|
|
1061
|
+
this.viewProps[propUri] = value
|
|
1048
1062
|
}
|
|
1049
1063
|
}
|
|
1050
1064
|
|
package/src/type-cache.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nextTick } from 'vue'
|
|
2
|
+
import { Topic, TopicType, AssocType, RoleType } from './model'
|
|
2
3
|
import rpc from './rpc'
|
|
3
4
|
import utils from './utils'
|
|
4
|
-
import Vue from 'vue'
|
|
5
5
|
|
|
6
6
|
const typeP = {} // intermediate type promises
|
|
7
7
|
|
|
@@ -87,7 +87,7 @@ const actions = {
|
|
|
87
87
|
}
|
|
88
88
|
// Note: role types are never updated as they are simple values and thus immutable
|
|
89
89
|
})
|
|
90
|
-
|
|
90
|
+
nextTick(() => {
|
|
91
91
|
// console.log(`Type-cache: processing ${directives.length} directives (DELETE_TYPE)`)
|
|
92
92
|
directives.forEach(dir => {
|
|
93
93
|
switch (dir.type) {
|
|
@@ -278,25 +278,21 @@ function _putType (type, typeClass, prop) {
|
|
|
278
278
|
if (!(type instanceof typeClass)) {
|
|
279
279
|
throw Error(`can't cache "${type.constructor.name}", expected is "${typeClass.name}", ${JSON.stringify(type)}`)
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
Vue.set(state[prop], type.uri, type)
|
|
281
|
+
state[prop][type.uri] = type
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
// ---
|
|
286
285
|
|
|
287
286
|
function removeTopicType (uri) {
|
|
288
|
-
|
|
289
|
-
Vue.delete(state.topicTypes, uri)
|
|
287
|
+
delete state.topicTypes[uri]
|
|
290
288
|
}
|
|
291
289
|
|
|
292
290
|
function removeAssocType (uri) {
|
|
293
|
-
|
|
294
|
-
Vue.delete(state.assocTypes, uri)
|
|
291
|
+
delete state.assocTypes[uri]
|
|
295
292
|
}
|
|
296
293
|
|
|
297
294
|
function removeRoleType (uri) {
|
|
298
|
-
|
|
299
|
-
Vue.delete(state.roleTypes, uri)
|
|
295
|
+
delete state.roleTypes[uri]
|
|
300
296
|
}
|
|
301
297
|
|
|
302
298
|
// ---
|