@bimdata/bcf-components 6.0.2-rc.1 → 6.0.2-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-rc.1",
3
+ "version": "6.0.2-rc.2",
4
4
  "files": [
5
5
  "src",
6
6
  "vue3-plugin.js"
@@ -44,7 +44,7 @@
44
44
 
45
45
  <script>
46
46
  import { EXTENSION_TYPES } from "../../config.js";
47
- import { useService } from "../../service.js";
47
+ import service from "../../service.js";
48
48
  // Components
49
49
  import SettingCard from "./setting-card/SettingCard.vue";
50
50
 
@@ -72,12 +72,12 @@ export default {
72
72
  emits: ["back", "close", "extension-created", "extension-updated", "extension-deleted"],
73
73
  setup(props, { emit }) {
74
74
  const createExtension = async (event) => {
75
- const ext = await useService().createExtension(props.project, event.extensionType, event.data);
75
+ const ext = await service.createExtension(props.project, event.extensionType, event.data);
76
76
  emit("extension-created", ext);
77
77
  };
78
78
 
79
79
  const updateExtension = async (event) => {
80
- const ext = await useService().updateExtension(
80
+ const ext = await service.updateExtension(
81
81
  props.project,
82
82
  event.extensionType,
83
83
  event.extension,
@@ -87,7 +87,7 @@ export default {
87
87
  };
88
88
 
89
89
  const deleteExtension = async (event) => {
90
- await useService().deleteExtension(props.project, event.extensionType, event.extension);
90
+ await service.deleteExtension(props.project, event.extensionType, event.extension);
91
91
  emit("extension-deleted", event.extension);
92
92
  };
93
93
 
@@ -197,7 +197,7 @@
197
197
 
198
198
  <script>
199
199
  import { computed, ref, watch } from "vue";
200
- import { useService } from "../../service.js";
200
+ import service from "../../service.js";
201
201
  import { getViewerList } from "../../utils/viewer.js";
202
202
  import { setViewpointDefaults } from "../../utils/viewpoints.js";
203
203
  // Components
@@ -391,8 +391,6 @@ export default {
391
391
  };
392
392
 
393
393
  const submit = async () => {
394
- const service = useService();
395
-
396
394
  if (!topicTitle.value) {
397
395
  hasErrorTitle.value = true;
398
396
  return;
@@ -232,7 +232,7 @@
232
232
  <script>
233
233
  import { adjustTextColor } from "@bimdata/design-system/src/BIMDataComponents/BIMDataColorSelector/colors.js";
234
234
  import { computed, onMounted, ref } from "vue";
235
- import { useService } from "../../service.js";
235
+ import service from "../../service.js";
236
236
  import { getPriorityColor } from "../../utils/topic.js";
237
237
  // Components
238
238
  import BcfTopicComments from "./bcf-topic-comments/BcfTopicComments.vue";
@@ -300,14 +300,14 @@ export default {
300
300
 
301
301
  const currentUserEmail = ref("");
302
302
  const loadCurrentUserEmail = async () => {
303
- currentUserEmail.value = (await useService().fetchCurrentUser()).email ?? "";
303
+ currentUserEmail.value = (await service.fetchCurrentUser()).email ?? "";
304
304
  };
305
305
 
306
306
  const deleteTopic = async () => {
307
307
  try {
308
308
  showDeleteModal.value = false;
309
309
  loading.value = true;
310
- await useService().deleteTopic(props.project, props.topic);
310
+ await service.deleteTopic(props.project, props.topic);
311
311
  emit("topic-deleted", props.topic);
312
312
  } catch (error) {
313
313
  console.error(error);
@@ -94,7 +94,7 @@
94
94
 
95
95
  <script>
96
96
  import { onMounted, inject, ref, watch, onBeforeUnmount } from "vue";
97
- import { useService } from "../../../service.js";
97
+ import service from "../../../service.js";
98
98
  import { getViewerOptions, highlightViewer, unhighlightViewer } from "../../../utils/viewer.js";
99
99
 
100
100
  // Components
@@ -142,7 +142,7 @@ export default {
142
142
  const viewerSelectOptions = ref([]);
143
143
 
144
144
  const loadComments = async () => {
145
- comments.value = await useService().fetchTopicComments(props.project, props.topic);
145
+ comments.value = await service.fetchTopicComments(props.project, props.topic);
146
146
  };
147
147
 
148
148
  const setCommentViewpoint = async () => {
@@ -165,7 +165,6 @@ export default {
165
165
 
166
166
  const submitComment = async () => {
167
167
  try {
168
- const service = useService();
169
168
  loading.value = true;
170
169
  if (viewpoint.value) {
171
170
  viewpoint.value = await service.createViewpoint(
@@ -138,7 +138,7 @@
138
138
 
139
139
  <script>
140
140
  import { inject, onMounted, ref, onBeforeUnmount } from "vue";
141
- import { useService } from "../../../../service.js";
141
+ import service from "../../../../service.js";
142
142
  import { getViewerOptions, highlightViewer, unhighlightViewer } from "../../../../utils/viewer.js";
143
143
 
144
144
  // TODO: should be imported from DS
@@ -189,7 +189,7 @@ export default {
189
189
  const toggleMenu = () => (showMenu.value = !showMenu.value);
190
190
 
191
191
  const loadViewpoint = async () => {
192
- viewpoint.value = await useService().fetchTopicCommentViewpoint(
192
+ viewpoint.value = await service.fetchTopicCommentViewpoint(
193
193
  props.project,
194
194
  props.topic,
195
195
  props.comment
@@ -206,7 +206,7 @@ export default {
206
206
  };
207
207
  const deleteViewpoint = async () => {
208
208
  if (viewpoint.value.guid) {
209
- await useService().deleteViewpoint(props.project, props.topic, viewpoint.value);
209
+ await service.deleteViewpoint(props.project, props.topic, viewpoint.value);
210
210
  }
211
211
  viewpoint.value = null;
212
212
  };
@@ -232,7 +232,7 @@ export default {
232
232
  return;
233
233
  }
234
234
  if (viewpoint.value && !viewpoint.value.guid) {
235
- viewpoint.value = await useService().createViewpoint(
235
+ viewpoint.value = await service.createViewpoint(
236
236
  props.project,
237
237
  props.topic,
238
238
  viewpoint.value
@@ -244,7 +244,7 @@ export default {
244
244
  ) {
245
245
  loading.value = true;
246
246
 
247
- const newComment = await useService().updateComment(
247
+ const newComment = await service.updateComment(
248
248
  props.project,
249
249
  props.topic,
250
250
  props.comment,
@@ -265,7 +265,7 @@ export default {
265
265
  const submitDelete = async () => {
266
266
  try {
267
267
  loading.value = true;
268
- await useService().deleteComment(props.project, props.topic, props.comment);
268
+ await service.deleteComment(props.project, props.topic, props.comment);
269
269
  emit("comment-deleted", props.comment);
270
270
  isDeleting.value = false;
271
271
  } finally {
package/src/index.js CHANGED
@@ -1,19 +1,11 @@
1
1
  import * as config from "./config.js";
2
- import { createService, setService, useService } from "./service.js";
2
+ import { getPriorityColor, getStatusColor } from "./utils/topic.js";
3
+ import { getViewpointConfig } from "./utils/viewpoints.js";
3
4
 
4
5
  import { useBcfFilter } from "./composables/filter.js";
5
6
  import { useBcfSearch } from "./composables/search.js";
6
7
  import { useBcfSort } from "./composables/sort.js";
7
8
 
8
- import {
9
- getPriorityColor,
10
- getStatusColor
11
- } from "./utils/topic.js";
12
-
13
- import {
14
- getViewpointConfig
15
- } from "./utils/viewpoints.js";
16
-
17
9
  import BcfFilters from "./components/bcf-filters/BcfFilters.vue";
18
10
  import BcfSettings from "./components/bcf-settings/BcfSettings.vue";
19
11
  import BcfStatistics from "./components/bcf-statistics/BcfStatistics.vue";
@@ -36,15 +28,12 @@ const components = {
36
28
 
37
29
  export {
38
30
  config,
39
- createService,
40
- setService,
41
- useService,
42
- useBcfFilter,
43
- useBcfSearch,
44
- useBcfSort,
45
31
  getPriorityColor,
46
32
  getStatusColor,
47
33
  getViewpointConfig,
34
+ useBcfFilter,
35
+ useBcfSearch,
36
+ useBcfSort,
48
37
  components,
49
38
 
50
39
  // Export components individually
package/src/service.js CHANGED
@@ -4,22 +4,29 @@ import { getExtensionField } from "./utils/extensions.js";
4
4
  import { getPriorityColor } from "./utils/topic.js";
5
5
  import { downloadBlobAs } from "./utils/download.js";
6
6
 
7
- let libService = null;
8
-
9
- function createService(apiClient, { fetchUsers }) {
10
- const getUsers = fetchUsers
11
- ? (project) => fetchUsers(project)
12
- : (project) => apiClient.collaborationApi.getProjectUsers(project.cloud.id, project.id);
13
-
14
- const fetchCurrentUser = () => apiClient.bcfApi.getUser();
7
+ class Service {
8
+ setup({ apiClient, fetchUsers }) {
9
+ this.apiClient = apiClient;
10
+ this.fetchUsers = fetchUsers;
11
+ }
12
+
13
+ _getUsers() {
14
+ return this.fetchUsers
15
+ ? (project) => this.fetchUsers(project)
16
+ : (project) => this.apiClient.collaborationApi.getProjectUsers(project.cloud.id, project.id);
17
+ }
18
+
19
+ fetchCurrentUser() {
20
+ return this.apiClient.bcfApi.getUser();
21
+ }
15
22
 
16
23
  // --- BCF Topics API ---
17
24
 
18
- const fetchTopics = async (project, { extensions, users } = {}) => {
19
- const _extensions = extensions ?? (await apiClient.bcfApi.getDetailedExtensions(project.id));
20
- const _users = users ?? (await getUsers(project));
25
+ async fetchTopics(project, { extensions, users } = {}) {
26
+ const _extensions = extensions ?? (await this.apiClient.bcfApi.getDetailedExtensions(project.id));
27
+ const _users = users ?? (await this._getUsers(project));
21
28
 
22
- const topics = await apiClient.bcfApi.getTopics(project.id);
29
+ const topics = await this.apiClient.bcfApi.getTopics(project.id);
23
30
  topics.sort((a, b) => b.index - a.index);
24
31
  topics.forEach((topic) => {
25
32
  topic.color = getPriorityColor(topic, _extensions);
@@ -27,180 +34,147 @@ function createService(apiClient, { fetchUsers }) {
27
34
  });
28
35
 
29
36
  return topics;
30
- };
37
+ }
31
38
 
32
- const fecthTopicByGuid = async (project, guid) => {
33
- const extensions = await apiClient.bcfApi.getDetailedExtensions(project.id);
34
- const topic = await apiClient.bcfApi.getFullTopic(guid, project.id, "url");
39
+ async fecthTopicByGuid(project, guid) {
40
+ const extensions = await this.apiClient.bcfApi.getDetailedExtensions(project.id);
41
+ const topic = await this.apiClient.bcfApi.getFullTopic(guid, project.id, "url");
35
42
  topic.color = getPriorityColor(topic, extensions);
36
43
  return topic;
37
- };
44
+ }
38
45
 
39
- const createTopic = (project, topic) => {
40
- return apiClient.bcfApi.createTopic(project.id, topic);
41
- };
46
+ createTopic(project, topic) {
47
+ return this.apiClient.bcfApi.createTopic(project.id, topic);
48
+ }
42
49
 
43
- const updateTopic = (project, topic) => {
44
- return apiClient.bcfApi.updateTopic(topic.guid, project.id, topic);
45
- };
50
+ updateTopic(project, topic) {
51
+ return this.apiClient.bcfApi.updateTopic(topic.guid, project.id, topic);
52
+ }
46
53
 
47
- const deleteTopic = (project, topic) => {
48
- return apiClient.bcfApi.deleteTopic(topic.guid, project.id);
49
- };
54
+ deleteTopic(project, topic) {
55
+ return this.apiClient.bcfApi.deleteTopic(topic.guid, project.id);
56
+ }
50
57
 
51
- const importBcf = async (project, file) => {
58
+ async importBcf(project, file) {
52
59
  const formData = new FormData();
53
60
  formData.append("name", file.name);
54
61
  formData.append("file", file);
55
- await fetch(`${apiClient.config.basePath}/bcf/2.1/projects/${project.id}/import`, {
62
+ await fetch(`${this.apiClient.config.basePath}/bcf/2.1/projects/${project.id}/import`, {
56
63
  method: "POST",
57
64
  credentials: "include",
58
65
  headers: {
59
- ...apiClient.authHeader,
66
+ ...this.apiClient.authHeader,
60
67
  },
61
68
  body: formData,
62
69
  });
63
- };
70
+ }
64
71
 
65
- const exportBcf = async (project, topics) => {
66
- const response = await apiClient.bcfApi.downloadBcfExport(
72
+ async exportBcf(project, topics) {
73
+ const response = await this.apiClient.bcfApi.downloadBcfExport(
67
74
  project.id,
68
75
  undefined, // Format
69
76
  topics.map((t) => t.guid).join(",")
70
77
  );
71
78
  downloadBlobAs(`${project.name}.bcf`, response);
72
- };
79
+ }
73
80
 
74
- const exportBcfXLSX = async (project, topics) => {
75
- const response = await apiClient.bcfApi.downloadBcfExportXlsx(
81
+ async exportBcfXLSX(project, topics) {
82
+ const response = await this.apiClient.bcfApi.downloadBcfExportXlsx(
76
83
  project.id,
77
84
  undefined, // Format
78
85
  undefined, // Locale
79
86
  topics.map((t) => t.guid).join(",")
80
87
  );
81
88
  downloadBlobAs(`${project.name}.xlsx`, response);
82
- };
89
+ }
83
90
 
84
91
  // --- BCF Topic Viewpoints API ---
85
92
 
86
- const loadTopicsViewpoints = async (project, topics) => {
87
- await eachLimit(topics, 10, (topic, cb) => {
93
+ async loadTopicsViewpoints(project, topics) {
94
+ await eachLimit(topics, 10, (topic, done) => {
88
95
  fetchTopicViewpoints(project, topic).then(viewpoints => {
89
96
  topic.viewpoints = viewpoints;
90
- cb();
91
- }, cb);
97
+ done();
98
+ }, done);
92
99
  });
93
100
  return topics;
94
- };
101
+ }
95
102
 
96
- const fetchTopicViewpoints = (project, topic) => {
97
- return apiClient.bcfApi.getTopicViewpoints(project.id, topic.guid, "url");
98
- };
103
+ fetchTopicViewpoints(project, topic) {
104
+ return this.apiClient.bcfApi.getTopicViewpoints(project.id, topic.guid, "url");
105
+ }
99
106
 
100
- const fetchTopicCommentViewpoint = (project, topic, comment) => {
101
- return apiClient.bcfApi.getViewpoint(comment.viewpoint_guid, project.id, topic.guid);
102
- };
107
+ fetchTopicCommentViewpoint(project, topic, comment) {
108
+ return this.apiClient.bcfApi.getViewpoint(comment.viewpoint_guid, project.id, topic.guid);
109
+ }
103
110
 
104
- const createViewpoint = (project, topic, viewpoint) => {
105
- return apiClient.bcfApi.createViewpoint(project.id, topic.guid, "url", viewpoint);
106
- };
111
+ createViewpoint(project, topic, viewpoint) {
112
+ return this.apiClient.bcfApi.createViewpoint(project.id, topic.guid, "url", viewpoint);
113
+ }
107
114
 
108
- const updateViewpoint = (project, topic, viewpoint) => {
109
- return apiClient.bcfApi.updateViewpoint(viewpoint.guid, project.id, topic.guid, "url", viewpoint);
110
- };
115
+ updateViewpoint(project, topic, viewpoint) {
116
+ return this.apiClient.bcfApi.updateViewpoint(viewpoint.guid, project.id, topic.guid, "url", viewpoint);
117
+ }
111
118
 
112
- const deleteViewpoint = (project, topic, viewpoint) => {
113
- return apiClient.bcfApi.deleteViewpoint(viewpoint.guid, project.id, topic.guid);
114
- };
119
+ deleteViewpoint(project, topic, viewpoint) {
120
+ return this.apiClient.bcfApi.deleteViewpoint(viewpoint.guid, project.id, topic.guid);
121
+ }
115
122
 
116
123
  // --- BCF Topic Comments API ---
117
124
 
118
- const fetchTopicComments = async (project, topic) => {
119
- const users = await getUsers(project);
125
+ async fetchTopicComments(project, topic) {
126
+ const users = await this._getUsers(project);
120
127
 
121
- const comments = await apiClient.bcfApi.getComments(project.id, topic.guid);
128
+ const comments = await this.apiClient.bcfApi.getComments(project.id, topic.guid);
122
129
  comments.sort((a, b) => (a.date > b.date ? -1 : 1));
123
130
  comments.forEach((c) => {
124
131
  c.user = users.find((u) => u.email === c.author);
125
132
  });
126
133
 
127
134
  return comments;
128
- };
135
+ }
129
136
 
130
- const createComment = (project, topic, data) => {
131
- return apiClient.bcfApi.createComment(project.id, topic.guid, data);
132
- };
137
+ createComment(project, topic, data) {
138
+ return this.apiClient.bcfApi.createComment(project.id, topic.guid, data);
139
+ }
133
140
 
134
- const updateComment = (project, topic, comment, data) => {
135
- return apiClient.bcfApi.updateComment(comment.guid, project.id, topic.guid, data);
136
- };
141
+ updateComment(project, topic, comment, data) {
142
+ return this.apiClient.bcfApi.updateComment(comment.guid, project.id, topic.guid, data);
143
+ }
137
144
 
138
- const deleteComment = (project, topic, comment) => {
139
- return apiClient.bcfApi.deleteComment(comment.guid, project.id, topic.guid);
140
- };
145
+ deleteComment(project, topic, comment) {
146
+ return this.apiClient.bcfApi.deleteComment(comment.guid, project.id, topic.guid);
147
+ }
141
148
 
142
149
  // --- BCF Extensions API ---
143
150
 
144
- const fetchExtensions = (project) => {
145
- return apiClient.bcfApi.getExtensions(project.id);
146
- };
151
+ fetchExtensions(project) {
152
+ return this.apiClient.bcfApi.getExtensions(project.id);
153
+ }
147
154
 
148
- const fetchDetailedExtensions = (project) => {
149
- return apiClient.bcfApi.getDetailedExtensions(project.id);
150
- };
155
+ fetchDetailedExtensions(project) {
156
+ return this.apiClient.bcfApi.getDetailedExtensions(project.id);
157
+ }
151
158
 
152
- const createExtension = async (project, type, data) => {
153
- return await apiClient.bcfApi[`createExtension${type}`](project.id, {
159
+ createExtension(project, type, data) {
160
+ return this.apiClient.bcfApi[`createExtension${type}`](project.id, {
154
161
  [getExtensionField(type)]: data.value,
155
162
  color: getRandomHexColor(),
156
163
  });
157
- };
164
+ }
158
165
 
159
- const updateExtension = async (project, type, extension, data) => {
160
- return await apiClient.bcfApi[`updateExtension${type}`](extension.id, project.id, {
166
+ updateExtension(project, type, extension, data) {
167
+ return this.apiClient.bcfApi[`updateExtension${type}`](extension.id, project.id, {
161
168
  [getExtensionField(type)]: data.value,
162
169
  color: data.color,
163
170
  });
164
- };
165
-
166
- const deleteExtension = async (project, type, extension) => {
167
- await apiClient.bcfApi[`deleteExtension${type}`](extension.id, project.id);
168
- };
169
-
170
- return {
171
- fetchCurrentUser,
172
- fetchTopics,
173
- fecthTopicByGuid,
174
- createTopic,
175
- updateTopic,
176
- deleteTopic,
177
- importBcf,
178
- exportBcf,
179
- exportBcfXLSX,
180
- loadTopicsViewpoints,
181
- fetchTopicViewpoints,
182
- fetchTopicCommentViewpoint,
183
- createViewpoint,
184
- updateViewpoint,
185
- deleteViewpoint,
186
- fetchTopicComments,
187
- createComment,
188
- updateComment,
189
- deleteComment,
190
- fetchExtensions,
191
- fetchDetailedExtensions,
192
- createExtension,
193
- updateExtension,
194
- deleteExtension,
195
- };
196
- }
171
+ }
197
172
 
198
- function setService(service) {
199
- libService = service;
173
+ deleteExtension(project, type, extension) {
174
+ return this.apiClient.bcfApi[`deleteExtension${type}`](extension.id, project.id);
175
+ }
200
176
  }
201
177
 
202
- function useService() {
203
- return libService;
204
- }
178
+ const service = new Service();
205
179
 
206
- export { createService, setService, useService };
180
+ export default service;
package/vue3-plugin.js CHANGED
@@ -1,9 +1,6 @@
1
- import {
2
- components,
3
- createService,
4
- setService,
5
- } from "./src/index.js";
1
+ import { components } from "./src/index.js";
6
2
  import messages from "./src/i18n/index.js";
3
+ import service from "./src/service.js";
7
4
 
8
5
  /**
9
6
  * BCF Components library plugin for Vue 3.
@@ -28,8 +25,7 @@ const pluginFactory = ({
28
25
  return {
29
26
  install(app) {
30
27
  if (apiClient) {
31
- const service = createService(apiClient, { fetchUsers });
32
- setService(service);
28
+ service.setup({ apiClient, fetchUsers });
33
29
  } else {
34
30
  console.error(
35
31
  "[BCF Components Plugin] No api client provided. " +