@dizmo/dcs-client-library 4.2.0 → 4.2.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.
@@ -140,7 +140,7 @@ class AllocationElement extends HTMLElement {
140
140
  this.shadowRoot.innerHTML = `
141
141
  <style>${this.getStyles()}</style>
142
142
  <div class="container">
143
- ${this.buildItemElement(item)}
143
+ ${this.buildItemElement(item, {}, this.getAttribute("leafType") || "resource")}
144
144
  <div class="info-section">${infoRows}</div>
145
145
  </div>
146
146
  `;
@@ -1,5 +1,8 @@
1
1
  // Shared web component that can display resource, package, need, and event items.
2
2
  import { ItemType } from "../types/types";
3
+ const packageIconLight = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#424142" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
4
+ const packageIconDark = `data:image/svg+xml,${encodeURIComponent('<svg width="27.5" height="27.5" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><path d="m4.42,22.06l0,-6.22l3.11,0l0,6.22l-3.11,0zm5.18,-6.22l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,-5.18l0,-5.18l3.11,0l0,5.18l-3.11,0zm5.18,11.41l0,-16.59l3.11,0l0,16.59l-3.11,0z" fill="#ffffff" transform="rotate(-90.2178 13.7484 13.7683)"/></svg>')}`;
5
+ const needBadgeIcon = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M477.28-240q21.96 0 37.3-15.34 15.33-15.33 15.33-37.32 0-21.99-15.33-37.18-15.34-15.18-37.3-15.18-21.95 0-37.29 15.18-15.34 15.19-15.34 37.18 0 21.99 15.34 37.32Q455.33-240 477.28-240ZM483.28-646.98q23.07 0 40.15 14.91 17.07 14.91 17.07 37.27 0 20.8-12.66 37.08-12.67 16.29-28.71 30.33-23 20-40.62 44.24-17.62 24.24-17.62 54.24 0 14.81 11.15 24.86Q463.2-394 478.07-394q15.93 0 27.15-10.6 11.21-10.6 15.17-26.31 4.48-20.05 17.64-35.71 13.17-15.66 28.45-29.95 23-21.76 39.02-48.11 16.02-26.36 16.02-58.12 0-51.48-41.14-84.58t-95.9-33.1q-38.96 0-73.82 16.48-34.86 16.48-53.81 49.96-7.48 12.71-4.76 27.16 2.73 14.45 14.71 21.95 14.72 8.71 30.8 5.35 16.07-3.35 27.03-17.83 10.52-14.05 26.09-21.81 15.58-7.76 32.56-7.76Z"/></svg>')}`;
3
6
  class ItemElement extends HTMLElement {
4
7
  constructor() {
5
8
  super();
@@ -35,8 +38,11 @@ class ItemElement extends HTMLElement {
35
38
  // Only resources show left image
36
39
  const showLeftImage = itemType === ItemType.Resource && (imgUrl || iconUrl);
37
40
  // Resources and needs show secondline, events show formatted date
41
+ const displaySecondLine = itemType === ItemType.Need && secondline
42
+ ? `${secondline} Need`
43
+ : secondline;
38
44
  const showSecondLine = (itemType === ItemType.Resource || itemType === ItemType.Need) &&
39
- secondline;
45
+ displaySecondLine;
40
46
  const showEventDate = itemType === ItemType.Event && secondline;
41
47
  // Format date for events
42
48
  const formattedDate = showEventDate ? formatDateToLocale(secondline) : null;
@@ -79,6 +85,9 @@ class ItemElement extends HTMLElement {
79
85
  overflow: hidden;
80
86
  text-overflow: ellipsis;
81
87
  }
88
+ .item_title.no-image {
89
+ margin-left: 6px;
90
+ }
82
91
  .item_first, .item_second {
83
92
  overflow: hidden;
84
93
  text-overflow: ellipsis;
@@ -109,6 +118,23 @@ class ItemElement extends HTMLElement {
109
118
  .invert {
110
119
  filter: invert(1);
111
120
  }
121
+ .need-badge {
122
+ position: absolute;
123
+ bottom: -3px;
124
+ right: -3px;
125
+ width: 16px;
126
+ height: 16px;
127
+ border-radius: 50%;
128
+ display: flex;
129
+ justify-content: center;
130
+ align-items: center;
131
+ pointer-events: none;
132
+ overflow: hidden;
133
+ }
134
+ .need-badge img {
135
+ width: 100%;
136
+ height: 100%;
137
+ }
112
138
  </style>
113
139
  <div class="item">
114
140
  ${showLeftImage
@@ -118,14 +144,15 @@ class ItemElement extends HTMLElement {
118
144
  </div>
119
145
  `
120
146
  : ""}
121
- <div class="item_title">
147
+ <div class="item_title${showLeftImage ? "" : " no-image"}">
122
148
  <div class="item_first">${firstline}</div>
123
- ${showSecondLine ? `<div class="item_second">${secondline}</div>` : ""}
149
+ ${showSecondLine ? `<div class="item_second">${displaySecondLine}</div>` : ""}
124
150
  ${showEventDate ? `<div class="item_second">${formattedDate}</div>` : ""}
125
151
  </div>
126
152
  <button class="item_button not-invert" id="open-item-btn" itemid="${itemId}"
127
153
  template="${template}" icolor="${color}"${color ? ` style="background-color: ${color} !important"` : ""}>
128
- <img class="item_button-image${invertIcon(color)}" loading="lazy" src="${iconUrl}" />
154
+ <img class="item_button-image${iconUrl ? invertIcon(color) : ""}" loading="lazy" src="${iconUrl || getDefaultIcon(itemType, color)}" />
155
+ ${itemType === ItemType.Need ? `<div class="need-badge" style="background-color: ${isIconInverted(color) ? "#ffffff" : "#000000"};"><img src="${needBadgeIcon}" style="${isIconInverted(color) ? "" : "filter: invert(1);"}"></div>` : ""}
129
156
  </button>
130
157
  </div>
131
158
  `;
@@ -148,6 +175,14 @@ const formatDateToLocale = (dateString) => {
148
175
  return dateString;
149
176
  }
150
177
  };
178
+ const getDefaultIcon = (itemType, color) => {
179
+ if (itemType === ItemType.Package) {
180
+ const isInverted = invertIcon(color) === " invert";
181
+ return isInverted ? packageIconDark : packageIconLight;
182
+ }
183
+ return "";
184
+ };
185
+ const isIconInverted = (color) => invertIcon(color) === " invert";
151
186
  const invertIcon = (backgroundColor) => {
152
187
  if (!backgroundColor ||
153
188
  backgroundColor === "transparent" ||
@@ -220,7 +220,7 @@ export type FullPackageAlloc = {
220
220
  startOffset: number;
221
221
  duration: number;
222
222
  leafId: string;
223
- leafData: ItemResult | null;
223
+ leafData: ItemResult | NeedResult | null;
224
224
  };
225
225
  export type ItemResult = {
226
226
  labels: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dizmo/dcs-client-library",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "A library that allows connection and management of dcs",
5
5
  "source": "source/index.ts",
6
6
  "main": "dist/index.js",