@bimdata/bcf-components 6.0.2 → 6.1.0-rc.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bimdata/bcf-components",
3
- "version": "6.0.2",
3
+ "version": "6.1.0-rc.2",
4
4
  "files": [
5
5
  "src",
6
6
  "vue3-plugin.js"
@@ -196,9 +196,8 @@
196
196
  </template>
197
197
 
198
198
  <script>
199
- import { computed, ref, watch } from "vue";
199
+ import { computed, inject, ref, watch } from "vue";
200
200
  import service from "../../service.js";
201
- import { getViewerList } from "../../utils/viewer.js";
202
201
  import { setViewpointDefaults } from "../../utils/viewpoints.js";
203
202
  // Components
204
203
  import BcfTopicImages from "./bcf-topic-images/BcfTopicImages.vue";
@@ -263,10 +262,6 @@ export default {
263
262
  */
264
263
  type: Array,
265
264
  },
266
- getViewers: {
267
- type: Function,
268
- default: () => () => ({})
269
- },
270
265
  },
271
266
  emits: [
272
267
  "back",
@@ -279,6 +274,8 @@ export default {
279
274
  "topic-update-error",
280
275
  ],
281
276
  setup(props, { emit }) {
277
+ const $viewer = inject("$viewer", null);
278
+
282
279
  const isCreation = computed(() => !props.topic);
283
280
  const nextIndex = computed(() => Math.max(0, ...props.topics.map((t) => t.index)) + 1);
284
281
 
@@ -349,9 +346,11 @@ export default {
349
346
 
350
347
  const createViewpoints = () => {
351
348
  Promise.all(
352
- getViewerList(props.getViewers()).map(viewer =>
353
- viewer.getViewpoint().then(viewpoint => viewpointsToCreate.value.push(viewpoint))
354
- )
349
+ ($viewer?.globalContext.getViewers() ?? [])
350
+ .filter(viewer => viewer.getLoadedModels().length > 0)
351
+ .map(viewer =>
352
+ viewer.getViewpoint().then(viewpoint => viewpointsToCreate.value.push(viewpoint))
353
+ )
355
354
  );
356
355
  };
357
356
 
@@ -449,8 +448,10 @@ export default {
449
448
 
450
449
  let newTopic;
451
450
  if (isCreation.value) {
452
- data.models = getViewerList(props.getViewers())
453
- .flatMap(v => v.getLoadedModels().map(m => m.id));
451
+ if ($viewer) {
452
+ data.models = $viewer.globalContext.getViewers()
453
+ .flatMap(v => v.getLoadedModels().map(m => m.id));
454
+ }
454
455
  newTopic = await service.createTopic(props.project, data);
455
456
  } else {
456
457
  newTopic = await service.updateTopic(props.project, data);
@@ -201,7 +201,6 @@
201
201
  :project="project"
202
202
  :topic="topic"
203
203
  :currentUserEmail="currentUserEmail"
204
- :getViewers="getViewers"
205
204
  @comment-created="$emit('comment-created', $event)"
206
205
  @comment-updated="$emit('comment-updated', $event)"
207
206
  @comment-deleted="$emit('comment-deleted', $event)"
@@ -269,10 +268,6 @@ export default {
269
268
  type: Object,
270
269
  required: true,
271
270
  },
272
- getViewers: {
273
- type: Function,
274
- default: () => () => ({})
275
- },
276
271
  },
277
272
  emits: [
278
273
  "back",
@@ -27,27 +27,29 @@
27
27
  <div class="flex items-center justify-between">
28
28
  <div class="flex items-center">
29
29
  <div
30
+ v-if="isViewer && !viewerSelectVisible"
30
31
  class="bcf-topic-comments__post-comment__camera m-r-12"
31
32
  @click="setCommentViewpoint"
32
- v-if="!viewerSelectVisible && isViewer"
33
33
  >
34
34
  <BIMDataIconCamera fill color="default" />
35
35
  </div>
36
36
  <BIMDataDropdownList
37
- v-if="viewerSelectVisible && isViewer"
37
+ v-if="isViewer && viewerSelectVisible"
38
38
  :list="viewerSelectOptions"
39
39
  elementKey="key"
40
40
  @element-click="createViewpoint"
41
41
  width="180px"
42
42
  >
43
- <template #header>{{ $t("BcfComponents.BcfTopicComments.takeSnapshot") }}</template>
43
+ <template #header>
44
+ {{ $t("BcfComponents.BcfTopicComments.takeSnapshot") }}
45
+ </template>
44
46
  <template #element="{ element }">
45
47
  <div
46
48
  style="width: 100%"
47
49
  @mouseenter="highlightViewer(element.viewer)"
48
50
  @mouseleave="unhighlightViewer(element.viewer)"
49
51
  >
50
- {{ `${element.id} (${element.index})` }}
52
+ {{ `(${element.index}) ${element.name}` }}
51
53
  </div>
52
54
  </template>
53
55
  </BIMDataDropdownList>
@@ -78,7 +80,6 @@
78
80
  :topic="topic"
79
81
  :comment="comment"
80
82
  :currentUserEmail="currentUserEmail"
81
- :get-viewers="getViewers"
82
83
  @comment-updated="onCommentUpdated"
83
84
  @comment-deleted="onCommentDeleted"
84
85
  @view-comment-snapshot="$emit('view-comment-snapshot', $event)"
@@ -121,10 +122,6 @@ export default {
121
122
  type: String,
122
123
  required: true,
123
124
  },
124
- getViewers: {
125
- type: Function,
126
- required: true,
127
- },
128
125
  },
129
126
  emis: ["comment-created", "comment-updated", "comment-deleted", "view-comment-snapshot"],
130
127
  setup(props, { emit }) {
@@ -207,12 +204,12 @@ export default {
207
204
 
208
205
  onMounted(() => {
209
206
  if ($viewer) {
210
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
207
+ viewerSelectOptions.value = getViewerOptions($viewer);
211
208
  pluginCreatedSub = $viewer.globalContext.hub.on("plugin-created", () => {
212
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
209
+ viewerSelectOptions.value = getViewerOptions($viewer);
213
210
  });
214
211
  pluginDestroyedSub = $viewer.globalContext.hub.on("plugin-destroyed", () => {
215
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
212
+ viewerSelectOptions.value = getViewerOptions($viewer);
216
213
  });
217
214
  }
218
215
  });
@@ -229,12 +226,12 @@ export default {
229
226
  comments,
230
227
  input,
231
228
  isOpen,
229
+ isViewer: Boolean($viewer),
232
230
  loading,
233
231
  text,
234
232
  viewerSelectOptions,
235
233
  viewerSelectVisible,
236
234
  viewpoint,
237
- isViewer: Boolean($viewer),
238
235
  // Methods
239
236
  createViewpoint,
240
237
  deleteViewpoint,
@@ -107,7 +107,7 @@
107
107
  @mouseenter="highlightViewer(element.viewer)"
108
108
  @mouseleave="unhighlightViewer(element.viewer)"
109
109
  >
110
- {{ `${element.id} (${element.index})` }}
110
+ {{ `(${element.index}) ${element.name}` }}
111
111
  </div>
112
112
  </template>
113
113
  </BIMDataDropdownList>
@@ -165,10 +165,6 @@ export default {
165
165
  type: String,
166
166
  required: true,
167
167
  },
168
- getViewers: {
169
- type: Function,
170
- required: true,
171
- },
172
168
  },
173
169
  emits: ["comment-updated", "comment-deleted", "view-comment-snapshot"],
174
170
  setup(props, { emit }) {
@@ -278,12 +274,12 @@ export default {
278
274
  await loadViewpoint();
279
275
  }
280
276
  if ($viewer) {
281
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
277
+ viewerSelectOptions.value = getViewerOptions($viewer);
282
278
  pluginCreatedSub = $viewer.globalContext.hub.on("plugin-created", () => {
283
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
279
+ viewerSelectOptions.value = getViewerOptions($viewer);
284
280
  });
285
281
  pluginDestroyedSub = $viewer.globalContext.hub.on("plugin-destroyed", () => {
286
- viewerSelectOptions.value = getViewerOptions(props.getViewers());
282
+ viewerSelectOptions.value = getViewerOptions($viewer);
287
283
  });
288
284
  }
289
285
  });
@@ -1,11 +1,6 @@
1
- export function getViewerList(viewers) {
2
- return Object.values(viewers).flat();
3
- }
4
-
5
- export function getViewerOptions(viewers) {
6
- return Object.entries(viewers)
7
- .map(([id, list]) => list.map((v, i) => ({ key: `${id}-${i}`, id, index: i, viewer: v })))
8
- .flat();
1
+ export function getViewerOptions($viewer) {
2
+ return $viewer.globalContext.getViewers()
3
+ .map((v, i) => ({ key: `${i}-${v.plugin.name}`, index: i, name: v.plugin.name, viewer: v }));
9
4
  }
10
5
 
11
6
  export function highlightViewer(viewer) {