architwin 1.0.75 → 1.0.76

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.
@@ -1,6 +1,6 @@
1
1
  import { _tagCategories, _tags, getMpTags } from "../../../architwin";
2
2
  import { convertToCssRgb, stringContains } from "../../../utils";
3
- import { renderTags, setSelectedCategoryFilter, setSelectedSubcategoryFilter, filterTagList } from './tagListPane';
3
+ import { renderTags, setSelectedCategoryFilter, setSelectedSubcategoryFilter, filterTagList, getAllSubcategories } from './tagListPane';
4
4
  let mode = 'adding';
5
5
  let tagNameInput, tagDescriptionInput, tagEmbedInput, tagCategoryDropdown, tagSubcategoryDropdown;
6
6
  let selectedCategoryId = undefined;
@@ -111,6 +111,19 @@ export function initFormData(tagId) {
111
111
  tagNameInput.value = targetTag.json_data.label;
112
112
  tagDescriptionInput.value = targetTag.json_data.description;
113
113
  tagEmbedInput.value = targetTag.media_url && targetTag.media_url !== '' ? targetTag.media_url : '';
114
+ const subcategories = getAllSubcategories();
115
+ const selectectedSubcategory = subcategories.find(sub => sub.uuid === targetTag.category_uuid);
116
+ if (selectectedSubcategory) {
117
+ const selectedCategory = _tagCategories.find(tag => tag.uuid === selectectedSubcategory.parent_uuid);
118
+ if (selectedCategory) {
119
+ console.log("Edit tag category found ", selectedCategory);
120
+ const catOption = createOptionElement(selectedCategory, 'category');
121
+ selectOption(catOption, 'at-category-dropdown-toggle', true);
122
+ }
123
+ console.log("Edit tag subcategory found ", selectectedSubcategory);
124
+ const subcatOption = createOptionElement(selectectedSubcategory, 'subcategory');
125
+ selectOption(subcatOption, 'at-subcategory-dropdown-toggle', true);
126
+ }
114
127
  // const tagCategoryOption = tagCategoryDropdown.querySelector(`option[value="${tagCategory.uuid}"]`) as HTMLOptionElement
115
128
  // if (tagCategoryOption) {
116
129
  // tagCategoryOption.selected = true;
@@ -293,7 +306,7 @@ export function toggleDropdown(elementId) {
293
306
  const dropdownOptions = document.getElementById(elementId);
294
307
  dropdownOptions.classList.toggle('open');
295
308
  }
296
- function selectOption(option, elementId) {
309
+ function selectOption(option, elementId, skipToggle = false) {
297
310
  console.log("selectOption()");
298
311
  //const dropdownToggle = document.querySelector('.at_dropdown_toggle');
299
312
  if (!elementId || elementId === '' || elementId == null) {
@@ -347,7 +360,32 @@ function selectOption(option, elementId) {
347
360
  else if (elementId === 'at-subcategory-filter-dropdown-toggle') {
348
361
  toggleId = 'at-subcategory-filter-options';
349
362
  }
350
- toggleDropdown(toggleId);
363
+ if (skipToggle == false) {
364
+ toggleDropdown(toggleId);
365
+ }
366
+ }
367
+ function createOptionElement(item, dropdownType) {
368
+ console.log("createOptionElement");
369
+ const option = document.createElement('div');
370
+ option.classList.add('at_option');
371
+ option.setAttribute('category-uuid', item.uuid);
372
+ option.setAttribute('dropdown-type', dropdownType);
373
+ option.setAttribute('data-cy', `at-category-option-${item.uuid}`);
374
+ if (dropdownType == 'category') {
375
+ option.innerHTML = `
376
+ <span class="at_colored-indicator" style="background-color:${convertToCssRgb(item.json_data.color.rgb)}"></span>
377
+ ${item.name}
378
+ `;
379
+ return option;
380
+ }
381
+ option.innerHTML = `
382
+ ${item.json_data.iconUrl ? `
383
+ <img class="at_avatar_xs" style="display:inline-block" src="${item.json_data.iconUrl}"/>
384
+ ` : `
385
+ <span class="at_colored-indicator" style="background-color:rgb(255,255,255)"></span>
386
+ `}
387
+ ${item.name}`;
388
+ return option;
351
389
  }
352
390
  export function renderCategoryDropdownOptions(elementId, items, toggleId) {
353
391
  console.log("renderCategoryDropdownOptions()");
@@ -374,16 +412,16 @@ export function renderCategoryDropdownOptions(elementId, items, toggleId) {
374
412
  return;
375
413
  }
376
414
  items.forEach(item => {
377
- console.log("Appending option ", toggleId);
378
- const option = document.createElement('div');
379
- option.classList.add('at_option');
380
- option.setAttribute('category-uuid', item.uuid);
381
- option.setAttribute('dropdown-type', 'category');
382
- option.setAttribute('data-cy', `at-category-option-${item.uuid}`);
383
- option.innerHTML = `
384
- <span class="at_colored-indicator" style="background-color:${convertToCssRgb(item.json_data.color.rgb)}"></span>
385
- ${item.name}
386
- `;
415
+ const option = createOptionElement(item, 'category');
416
+ // const option = document.createElement('div')
417
+ // option.classList.add('at_option')
418
+ // option.setAttribute('category-uuid',item.uuid)
419
+ // option.setAttribute('dropdown-type','category')
420
+ // option.setAttribute('data-cy',`at-category-option-${item.uuid}`)
421
+ // option.innerHTML = `
422
+ // <span class="at_colored-indicator" style="background-color:${convertToCssRgb(item.json_data.color.rgb)}"></span>
423
+ // ${item.name}
424
+ // `
387
425
  option.onclick = () => {
388
426
  selectOption(option, toggleId ? toggleId : 'at-category-dropdown-toggle');
389
427
  };
@@ -421,19 +459,20 @@ export function renderSubcategoryDropdownOptions(elementId, items) {
421
459
  return;
422
460
  }
423
461
  items.forEach(item => {
424
- const option = document.createElement('div');
425
- option.classList.add('at_option');
426
- option.setAttribute('category-uuid', item.uuid);
427
- option.setAttribute('dropdown-type', 'subcategory');
428
- option.setAttribute('data-cy', `at-category-option-${item.uuid}`);
429
- option.innerHTML = `
430
- ${item.json_data.iconUrl ? `
431
- <img class="at_avatar_xs" style="display:inline-block" src="${item.json_data.iconUrl}"/>
432
- ` : `
433
- <span class="at_colored-indicator" style="background-color:rgb(255,255,255)"></span>
434
- `}
435
- ${item.name}
436
- `;
462
+ const option = createOptionElement(item, 'subcategory');
463
+ // const option = document.createElement('div')
464
+ // option.classList.add('at_option')
465
+ // option.setAttribute('category-uuid',item.uuid)
466
+ // option.setAttribute('dropdown-type','subcategory')
467
+ // option.setAttribute('data-cy',`at-category-option-${item.uuid}`)
468
+ // option.innerHTML = `
469
+ // ${item.json_data.iconUrl ? `
470
+ // <img class="at_avatar_xs" style="display:inline-block" src="${item.json_data.iconUrl}"/>
471
+ // ` : `
472
+ // <span class="at_colored-indicator" style="background-color:rgb(255,255,255)"></span>
473
+ // `}
474
+ // ${item.name}
475
+ // `
437
476
  option.onclick = () => {
438
477
  selectOption(option, isFilterDropdown ? 'at-subcategory-filter-dropdown-toggle' : 'at-subcategory-dropdown-toggle');
439
478
  };
@@ -158,10 +158,10 @@ export function renderTags(tags) {
158
158
  batchAddEventListenerByClassName('at_tag_row', (event) => __awaiter(this, void 0, void 0, function* () {
159
159
  console.log('Event', event);
160
160
  //@ts-ignore
161
- const tagRow = document.getElementById(event.target.id);
161
+ const tagRow = event.target.closest('.at_tag_row');
162
162
  if (tagRow) {
163
- const tagId = tagRow.getAttribute('tag-id');
164
- if (tagId) {
163
+ const tagId = tagRow.children[1].getAttribute('tag-id');
164
+ if (tagId && tagId != null) {
165
165
  yield gotoTag(tagId);
166
166
  }
167
167
  }
package/lib/tag.js CHANGED
@@ -102,19 +102,19 @@ function setTagIcon(payload) {
102
102
  // get color as image
103
103
  const colorImg = getTagColorImageSrc(payload.color);
104
104
  console.log('__@ ICON colorImg:', colorImg);
105
- const colorImageRes = yield axios.get(colorImg
106
- // {
107
- // responseType: 'arraybuffer',
108
- // }
109
- );
105
+ const colorImageRes = yield axios.get(colorImg, {
106
+ responseType: 'arraybuffer',
107
+ });
110
108
  console.log('__@ ICON responsessss:', colorImageRes.data);
111
- const response = yield axios.get(payload.icon);
109
+ const response = yield axios.get(payload.icon, {
110
+ responseType: 'arraybuffer',
111
+ });
112
112
  console.log('__@ ICON response:', JSON.stringify(response));
113
113
  // convert image to base64
114
- const base64 = arrayBufferToBase64(response);
115
- console.log('__@ ICON base64:', colorImg);
114
+ const base64 = arrayBufferToBase64(response.data);
115
+ console.log('__@ ICON base64:', base64);
116
116
  const colorImgB64 = arrayBufferToBase64(colorImageRes.data);
117
- console.log('__@ ICON colorImgB64:', colorImg);
117
+ console.log('__@ ICON colorImgB64:', colorImgB64);
118
118
  const base64Image = `data:image/jpeg;base64,${base64}`;
119
119
  const colorBase64Image = `data:image/jpeg;base64,${colorImgB64}`;
120
120
  // merge bg color image and icon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",