architwin 1.12.4 → 1.12.5

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.
@@ -15,3 +15,7 @@ export declare function getTagMessageText(): string;
15
15
  export declare function clearTagMessageInput(): void;
16
16
  export declare function createTagMessage(): TagMessage;
17
17
  export declare function setTagMessagingDetails(tagId: string): void;
18
+ export declare function unsendComment(payload: any): void;
19
+ export declare function timedoutComment(payload: Array<TagMessage>): void;
20
+ export declare function checkTimeoutDifference(createdDateInput: Date, mode: string): boolean;
21
+ export declare function getTheseTagMessages(payload: Array<TagMessage>): TagMessage[];
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { getTagMessageRecepients, getTagMessages, getSelectedTagUuid, dispatchSpaceEvent, _tags } from "../../../architwin";
2
11
  import { SPACE_EVENTS } from "../../../types";
3
12
  import { bytesToMegabytes, convertToCssRgb, generateUUID } from "../../../utils";
@@ -7,7 +16,9 @@ import { parseISO } from 'date-fns';
7
16
  import { formatWithOptions } from "date-fns/fp";
8
17
  import { ja } from "date-fns/locale";
9
18
  import i18n from './i18n';
19
+ import { batchAddEventListenerByClassName } from '../../events';
10
20
  let notyf = new Notyf({ position: { x: 'left', y: 'bottom' } });
21
+ let theseTagMessages = [];
11
22
  export function renderTagMessagingPane() {
12
23
  const element = document.createElement('div');
13
24
  element.classList.add('at_container');
@@ -140,7 +151,11 @@ export function renderTagMessage(message, optimisticUpdate = false) {
140
151
  `
141
152
  <img class="at_chat_media" src="${message.image_url}"/><br>
142
153
  ` : ``}
143
- <small>${created_on}</small>
154
+ <small>${created_on}</small><br>
155
+ <div class="at_flex at_justify_center at_comment_unsend_container" style="${checkTimeoutDifference(message.created_on, 'check') == true ? 'at_comment_unsend_container' : 'display: none'} id="at-unsend-container-${message.uuid}">
156
+ <small class="mdi mdi-arrow-u-left-top at_text_xxs at_align_center at_comment_unsend_text">&nbsp;</small>
157
+ <small class="at_text_xxs at_align_center at_comment_unsend_text" id="at-unsend-user-text-${created_on}">Unsend</small>
158
+ </div>
144
159
  </div>
145
160
  </div>
146
161
  `;
@@ -152,8 +167,8 @@ export function renderTagMessage(message, optimisticUpdate = false) {
152
167
  }
153
168
  else {
154
169
  chat.innerHTML = `
155
- <span class="at_chat_avatar at_chat_avatar_sender">${message.owner_name.charAt(0).toUpperCase()}</span>
156
- <div class="at_chat_bubble at_chat_bubble_sent">
170
+ <span class="at_chat_avatar at_chat_avatar_sender" id="at-chat-avatar-container-${message.uuid}">${message.owner_name.charAt(0).toUpperCase()}</span>
171
+ <div class="at_chat_bubble at_chat_bubble_sent" id="at-chat-bubble-container-${message.uuid}">
157
172
  <div>
158
173
  <small>${message.owner_name} ➡️ ${message.to_user_name}</small> <br>
159
174
  ${message.messages}
@@ -162,8 +177,13 @@ export function renderTagMessage(message, optimisticUpdate = false) {
162
177
  `
163
178
  <img class="at_chat_media" src="${message.image_url}"/><br>
164
179
  ` : ``}
165
- <small>${created_on}</small>
180
+ <small>${created_on}</small><br>
181
+ <div class="at_flex at_justify_center at_comment_unsend_container" id="at-unsend-container-${message.uuid}" style="${checkTimeoutDifference(message.created_on, 'check') == true ? 'at_comment_unsend_container' : 'display: none'}">
182
+ <small class="mdi mdi-arrow-u-left-top at_text_xxs at_align_center at_comment_unsend_text">&nbsp;</small>
183
+ <small class="at_text_xxs at_align_center at_comment_unsend_text" id="at-unsend-admin-text-${message.uuid}" value="${message.uuid}">Unsend</small>
184
+ </div>
166
185
  </div>
186
+
167
187
  </div>
168
188
  `;
169
189
  }
@@ -171,13 +191,20 @@ export function renderTagMessage(message, optimisticUpdate = false) {
171
191
  const firstChild = chatContainer.firstChild;
172
192
  chatContainer.insertBefore(chat, firstChild);
173
193
  const input = (document.getElementById("at-no-message"));
174
- input.remove();
175
- return;
194
+ if (input)
195
+ input.remove();
196
+ // return
176
197
  }
177
198
  else {
178
199
  chatContainer.appendChild(chat);
179
- return;
180
200
  }
201
+ chat.addEventListener('click', (event) => {
202
+ //@ts-expect-error
203
+ const newMessage = event.target.getAttribute('value');
204
+ console.log('___chat is clicked', newMessage, message);
205
+ unsendComment({ newMessage });
206
+ });
207
+ return;
181
208
  }
182
209
  export function getSelectedMessageRecepient() {
183
210
  const recepientDropdown = document.getElementById('at-recepient-dropdown');
@@ -220,6 +247,7 @@ export function getTagMessageText() {
220
247
  return content;
221
248
  }
222
249
  export function clearTagMessageInput() {
250
+ console.log('clearTagMessageInput()');
223
251
  const textareaInput = document.getElementById('at-chat-textarea');
224
252
  textareaInput.value = '';
225
253
  }
@@ -261,16 +289,18 @@ export function createTagMessage() {
261
289
  message.created_on = created_on;
262
290
  dispatchSpaceEvent(SPACE_EVENTS.TAG_MESSAGE_SENT, message);
263
291
  // add remove span
292
+ //clear input field
293
+ clearTagMessageInput();
264
294
  //Perform optimistic update
265
- renderTagMessage(message, true);
295
+ renderTagMessage(message, false); //change to false due to Unsend Option #15713
266
296
  //Clear forms
267
297
  clearSelectedMedia();
268
- clearTagMessageInput();
269
298
  notyf.success(`${i18n.t('MessageSentSuccess')}`);
299
+ getTagMessages();
270
300
  return message;
271
301
  }
272
302
  export function setTagMessagingDetails(tagId) {
273
- console.log("setTagMessagingDetails()", tagId);
303
+ console.log("setTagMessagingDetails() ", tagId);
274
304
  if (tagId && tagId !== '') {
275
305
  const tagTitle = document.getElementById('at-tag-name-messaging');
276
306
  const tagColor = document.getElementById('at-tag-color-messaging');
@@ -299,3 +329,80 @@ export function setTagMessagingDetails(tagId) {
299
329
  console.error("tagId is either undefined or empty");
300
330
  return;
301
331
  }
332
+ // this deletes a selected Chat Bubble
333
+ export function unsendComment(payload) {
334
+ console.log('___unsendComment()', payload);
335
+ batchAddEventListenerByClassName('at_comment_unsend_container', (event) => __awaiter(this, void 0, void 0, function* () {
336
+ console.log('__batch event', event);
337
+ //@ts-ignore
338
+ const commentTag = event.target.getAttribute('value');
339
+ if (commentTag && payload.tagMessages) {
340
+ console.log('__comment uuid: ', payload.tagMessages);
341
+ const commentFound = payload.tagMessages.find((message) => {
342
+ return message.uuid == commentTag;
343
+ });
344
+ if (commentFound && checkTimeoutDifference(commentFound.created_on, 'delete') == true) {
345
+ dispatchSpaceEvent(SPACE_EVENTS.TAG_MESSAGE_UNSEND, { uuid: commentFound.uuid, tagId: commentFound.tag_uuid });
346
+ hideTagBubble(commentFound.uuid);
347
+ }
348
+ }
349
+ }));
350
+ }
351
+ // this sets the Interval to check if Timeout hadn't pass yet
352
+ export function timedoutComment(payload) {
353
+ console.log('timedoutComment()', payload);
354
+ setInterval(function () {
355
+ // console.log("This message prints every 5 seconds.", payload);
356
+ payload.filter((message) => __awaiter(this, void 0, void 0, function* () {
357
+ const difference = yield checkTimeoutDifference(parseISO(message.created_on), 'check');
358
+ const container = document.getElementById(`at-unsend-container-${message.uuid}`);
359
+ if (difference == true && container) {
360
+ // console.log('difference test: ', difference)
361
+ // container.style.display = 'block'
362
+ }
363
+ else if (difference == false && container) {
364
+ container.style.display = 'none';
365
+ // console.log('This message print UNSEND STILL AVAIABLE')
366
+ }
367
+ }));
368
+ }, 5000);
369
+ }
370
+ // this compares the created_on and current Time of User its within Timeout
371
+ export function checkTimeoutDifference(createdDateInput, mode) {
372
+ const createdDate = new Date(createdDateInput);
373
+ const currentDate = new Date();
374
+ const difference = currentDate.getTime() - createdDate.getTime();
375
+ const TIMEOUT = 10 * 60 * 1000;
376
+ if (mode == 'check') {
377
+ if (difference <= TIMEOUT) {
378
+ timedoutComment(theseTagMessages);
379
+ return true;
380
+ }
381
+ else {
382
+ return false;
383
+ }
384
+ }
385
+ else if (mode == 'delete') {
386
+ if (difference <= TIMEOUT) {
387
+ return true;
388
+ }
389
+ else {
390
+ return false;
391
+ }
392
+ }
393
+ }
394
+ // this function hides the selected Chat Bubble while it is being deleted
395
+ function hideTagBubble(payload) {
396
+ console.log('hideTagBubble()', payload);
397
+ const chatContainer = document.getElementById(`at-chat-bubble-container-${payload}`);
398
+ const chaAvatar = document.getElementById(`at-chat-avatar-container-${payload}`);
399
+ if (chatContainer && chaAvatar) {
400
+ chatContainer.style.display = 'none';
401
+ chaAvatar.style.display = 'none';
402
+ }
403
+ }
404
+ // this gets the tagMessages
405
+ export function getTheseTagMessages(payload) {
406
+ console.log('getTheseTagMessages()');
407
+ return theseTagMessages = payload;
408
+ }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { actionBar, renderObjectCards, renderLibraryCards, renderTags, renderTagRow, getTagFormData, addClickEventToTagRow, setActiveCard, setActiveMenu, removeObjectCard, clearActiveMenu, setTagCategoriesOption, toggleDropdown, tagFormMode, selectedTag, renderRecepientOptions, renderTagMessages, createTagMessage, setTagLink, setTagMessagingDetails, renderCategoryDropdownOptions, clearTagFormDropdown, clearActiveActionBtn, clearActiveCard, toggleActionBarButtons, selectedCategoryFilterId, selectedSubCategoryFilterId, filterTagList, toggleModal, setModalAction, } from "./components/toolbar";
11
- import { getTargetPosition, addMediaScreen, _3DXObjects, selectedObject, setTransformControls, copyObject, revertTransform, clearSelectedObject, removeTransformControls, getLibrary, getMpTags, renderTag, captureSpaceScreenshot, moveTag, subscribeSpaceEvent, setModelVisibility, disposeModel, disposeTag, _tags, _tagCategories, dispatchSpaceEvent, editTagLabel, editTagDescription, setTagMessageRecepients, setTagMessages, setSelectedTagUuid, renderMeetingSidebar, setTagIcon, setObjectTransformation, getSelectedObject, _atwin, isCdnMapDataAvailable, captureScreenshotAndCameraDetails, _mpConfig, cancelModelPlacement, _modelDetails, actionHistory, get3DXObjects, transformHistory, goToModel, themeManager, _partitionNodes, setSpacePartitionNodes, getSpaceId, setFloorBaseHeight, toggleWallVisibility, getChildrenOfModel, toggleFloorVisibility, renderPolygon, getCurrentPolygon, getFloorBaseHeight, setSelectedObject, redoDrawAction, undoDrawAction, setWallBaseHeight, clearWallBaseHeight, clearFloorBaseHeight, isToolbarFeatureEnabled, captureCurrentView, getCurrentFloor, } from "../architwin";
11
+ import { getTargetPosition, addMediaScreen, _3DXObjects, selectedObject, setTransformControls, copyObject, revertTransform, clearSelectedObject, removeTransformControls, getLibrary, getMpTags, renderTag, captureSpaceScreenshot, moveTag, subscribeSpaceEvent, setModelVisibility, disposeModel, disposeTag, _tags, _tagCategories, dispatchSpaceEvent, editTagLabel, editTagDescription, setTagMessageRecepients, setTagMessages, setSelectedTagUuid, renderMeetingSidebar, setTagIcon, setObjectTransformation, getSelectedObject, _atwin, isCdnMapDataAvailable, captureScreenshotAndCameraDetails, _mpConfig, cancelModelPlacement, _modelDetails, actionHistory, get3DXObjects, transformHistory, goToModel, themeManager, _partitionNodes, setSpacePartitionNodes, getSpaceId, setFloorBaseHeight, toggleWallVisibility, getChildrenOfModel, toggleFloorVisibility, renderPolygon, getCurrentPolygon, getFloorBaseHeight, setSelectedObject, redoDrawAction, undoDrawAction, setWallBaseHeight, clearWallBaseHeight, clearFloorBaseHeight, isToolbarFeatureEnabled, captureCurrentView, getCurrentFloor, detachTagMedia, getTagDataCollection } from "../architwin";
12
12
  import { Notyf } from 'notyf';
13
13
  import 'notyf/notyf.min.css';
14
14
  import { SPACE_EVENTS, COORDINATE_SYSTEM, UNITS, DEGREE, MAP_OPTIONS } from "../types";
@@ -29,6 +29,7 @@ import { actionSettingsSelectOption, getTempCoordinateSystem, getTempMeasurement
29
29
  import { getBasepointCalibrateBpCoordinateValues, getBasepointCalibrateMpCoordinateValues, initBsepointCalibratePane, toggleBasepointCalibratePane } from "./components/toolbar/basepointCalibratePane";
30
30
  import { toggleGeneralMapOptions, initGeneralSelectedMap, getSelectedMapOption } from './components/toolbar/generalSettingsMenuPane';
31
31
  import { searchTagList, setSearchTagTerm, searchClearfield, getSearchTagTerm } from './components/toolbar/tagListPane';
32
+ import { unsendComment, timedoutComment, getTheseTagMessages } from './components/toolbar/tagMessagingPane';
32
33
  let activeToolbarItem, activeActionItem, activePane, activeActionPane, cancelTagPlacementPrompt, cancelModelPlacementPrompt;
33
34
  let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500, types: [
34
35
  {
@@ -863,11 +864,13 @@ function handleSaveTag() {
863
864
  const index = _tags.findIndex(tag => tag.id == selectedTag.id);
864
865
  //Check if object contains a url embed and if the url does not match the existing url in media url
865
866
  //perform a validation of the new url embed
866
- if (tagFormPayload && tagFormPayload.tagEmbed && _tags[index].media_url !== tagFormPayload.tagEmbed) {
867
- if ((yield isValidUrl(tagFormPayload.tagEmbed)) === false) {
868
- notyf.error(`${i18n.t('InvalidURL')}`);
869
- saveTagBtn.classList.remove('at_disabled');
870
- return;
867
+ if (tagFormPayload && tagFormPayload.tagEmbed != '') { // this condition is added when Embed URL is removed by user and is Empty #15842
868
+ if (tagFormPayload && tagFormPayload.tagEmbed && _tags[index].media_url !== tagFormPayload.tagEmbed) {
869
+ if ((yield isValidUrl(tagFormPayload.tagEmbed)) === false) {
870
+ notyf.error(`${i18n.t('InvalidURL')}`);
871
+ saveTagBtn.classList.remove('at_disabled');
872
+ return;
873
+ }
871
874
  }
872
875
  }
873
876
  if (_tagCategories) {
@@ -915,15 +918,26 @@ function handleSaveTag() {
915
918
  }
916
919
  _tags[index].category_uuid = tagFormPayload.tagSubcategoryId;
917
920
  _tags[index].json_data.color = targetCategory.json_data.color.rgb;
918
- if (tagFormPayload.tagEmbed !== _tags[index].media_url) {
919
- const tagData = {
920
- id: _tags[index].json_data.id,
921
- attachments: []
922
- };
923
- const mediaAttachment = [tagFormPayload.tagEmbed];
924
- yield attachTagMedia({ sdk: _atwin, tag: tagData, attachments: mediaAttachment });
921
+ if (tagFormPayload.tagEmbed && tagFormPayload.tagEmbed != '') { // this condition is added when Embed URL is removed by user and is Empty #15842
922
+ if (tagFormPayload.tagEmbed !== _tags[index].media_url) {
923
+ const tagData = {
924
+ id: _tags[index].json_data.id,
925
+ attachments: []
926
+ };
927
+ const mediaAttachment = [tagFormPayload.tagEmbed];
928
+ const attachments = yield attachTagMedia({ sdk: _atwin, tag: tagData, attachments: mediaAttachment });
929
+ }
930
+ _tags[index].media_url = tagFormPayload.tagEmbed;
931
+ }
932
+ else {
933
+ _tags[index].media_url = undefined;
934
+ const tagDataCollection = getTagDataCollection();
935
+ _tags[index].json_data.attachments = tagDataCollection[_tags[index].json_data.id] ? tagDataCollection[_tags[index].json_data.id].attachments : _tags[index].json_data.attachments;
936
+ if (_tags[index].json_data.attachments) {
937
+ yield detachTagMedia({ tagId: _tags[index].json_data.id, attachmentIds: _tags[index].json_data.attachments });
938
+ _tags[index].json_data.attachments = [];
939
+ }
925
940
  }
926
- _tags[index].media_url = tagFormPayload.tagEmbed;
927
941
  // Add tag icon data
928
942
  _tags[index].tag_icon_name = thisTagIconName;
929
943
  _tags[index].tag_icon_url = thisTagIconURL;
@@ -1412,6 +1426,9 @@ function handleRetrieveTagMessage(payload) {
1412
1426
  renderRecepientOptions();
1413
1427
  renderTagMessages();
1414
1428
  setTagMessagingDetails(payload.tagUuid);
1429
+ unsendComment(payload);
1430
+ getTheseTagMessages(payload.tagMessages);
1431
+ timedoutComment(payload.tagMessages);
1415
1432
  }
1416
1433
  function handleSetModelsView() {
1417
1434
  const modelsCardViewBtn = document.getElementById('at-models-card-view-btn');
package/lib/tag.d.ts CHANGED
@@ -28,7 +28,7 @@ declare function attachTagMedia(payload: {
28
28
  sdk: MpSdk;
29
29
  tag: MpSdk.Tag.TagData;
30
30
  attachments: string[];
31
- }): Promise<void>;
31
+ }): Promise<string[]>;
32
32
  declare function detachTagMedia(payload: {
33
33
  sdk: MpSdk;
34
34
  tag: ITag;
package/lib/tag.js CHANGED
@@ -136,10 +136,12 @@ function attachTagMedia(payload) {
136
136
  payload.tag.attachments = [];
137
137
  for (let i in payload.attachments) {
138
138
  const [attachmentId] = yield payload.sdk.Tag.registerAttachment(payload.attachments[i]);
139
+ log.info("media attachmentId ", attachmentId);
139
140
  payload.tag.attachments.push(attachmentId);
140
141
  }
141
142
  yield payload.sdk.Tag.attach(payload.tag.id, ...payload.tag.attachments);
142
143
  log.info('__@ Attach successfully');
144
+ return payload.tag.attachments;
143
145
  });
144
146
  }
145
147
  function detachTagMedia(payload) {
package/lib/types.d.ts CHANGED
@@ -730,7 +730,8 @@ export declare enum SPACE_EVENTS {
730
730
  CUSTOM_SWEEP_OFFSETX_UPDATED = "CUSTOM_SWEEP_OFFSETX_UPDATED",
731
731
  CUSTOM_SWEEP_OFFSETY_UPDATED = "CUSTOM_SWEEP_OFFSETY_UPDATED",
732
732
  CUSTOM_MAP_SETTINGS_UPDATED = "CUSTOM_MAP_SETTINGS_UPDATED",
733
- SPACE_METADATA_RETRIEVED = "SPACE_METADATA_RETRIEVED"
733
+ SPACE_METADATA_RETRIEVED = "SPACE_METADATA_RETRIEVED",
734
+ TAG_MESSAGE_UNSEND = "TAG_MESSAGE_UNSEND"
734
735
  }
735
736
  export declare const enum TAG_COLOR {
736
737
  MAROON = "MAROON",
package/lib/types.js CHANGED
@@ -107,6 +107,7 @@ export var SPACE_EVENTS;
107
107
  SPACE_EVENTS["CUSTOM_SWEEP_OFFSETY_UPDATED"] = "CUSTOM_SWEEP_OFFSETY_UPDATED";
108
108
  SPACE_EVENTS["CUSTOM_MAP_SETTINGS_UPDATED"] = "CUSTOM_MAP_SETTINGS_UPDATED";
109
109
  SPACE_EVENTS["SPACE_METADATA_RETRIEVED"] = "SPACE_METADATA_RETRIEVED";
110
+ SPACE_EVENTS["TAG_MESSAGE_UNSEND"] = "TAG_MESSAGE_UNSEND";
110
111
  })(SPACE_EVENTS || (SPACE_EVENTS = {}));
111
112
  export var MEETING_SIDEBAR;
112
113
  (function (MEETING_SIDEBAR) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.12.4",
3
+ "version": "1.12.5",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",
@@ -1801,3 +1801,7 @@
1801
1801
  .at_default_coordinate_system {
1802
1802
  margin-top: 15px;
1803
1803
  }
1804
+
1805
+ .at_comment_unsend_container{
1806
+ cursor: pointer;
1807
+ }