@processmaker/screen-builder 3.0.1 → 3.0.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": "@processmaker/screen-builder",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -57,7 +57,7 @@
57
57
  "@fortawesome/fontawesome-free": "^5.6.1",
58
58
  "@originjs/vite-plugin-commonjs": "^1.0.3",
59
59
  "@panter/vue-i18next": "^0.15.2",
60
- "@processmaker/vue-form-elements": "0.60.0",
60
+ "@processmaker/vue-form-elements": "0.61.0",
61
61
  "@processmaker/vue-multiselect": "2.3.0",
62
62
  "@storybook/addon-essentials": "^7.6.13",
63
63
  "@storybook/addon-interactions": "^7.6.13",
@@ -116,7 +116,7 @@
116
116
  },
117
117
  "peerDependencies": {
118
118
  "@panter/vue-i18next": "^0.15.0",
119
- "@processmaker/vue-form-elements": "0.60.0",
119
+ "@processmaker/vue-form-elements": "0.61.0",
120
120
  "i18next": "^15.0.8",
121
121
  "vue": "^2.6.12",
122
122
  "vuex": "^3.1.1"
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="18" viewBox="0 0 16 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M10.2837 6.5L9.99519 14M6.00481 14L5.71635 6.5M14.023 3.82547C14.308 3.86851 14.592 3.91456 14.875 3.96358M14.023 3.82547L13.1332 15.3938C13.058 16.3707 12.2434 17.125 11.2637 17.125H4.73631C3.75655 17.125 2.94198 16.3707 2.86683 15.3938L1.97696 3.82547M14.023 3.82547C13.0677 3.6812 12.1013 3.57071 11.125 3.49527M1.125 3.96358C1.40798 3.91456 1.69198 3.86851 1.97696 3.82547M1.97696 3.82547C2.93231 3.6812 3.89874 3.57071 4.875 3.49527M11.125 3.49527V2.73182C11.125 1.74902 10.3661 0.928526 9.38382 0.897103C8.92435 0.882405 8.46304 0.875 8 0.875C7.53696 0.875 7.07565 0.882405 6.61618 0.897103C5.63388 0.928526 4.875 1.74902 4.875 2.73182V3.49527M11.125 3.49527C10.0938 3.41558 9.05164 3.375 8 3.375C6.94836 3.375 5.9062 3.41558 4.875 3.49527" stroke="#596372" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M14.0514 3.73889L15.4576 2.33265C16.0678 1.72245 17.0572 1.72245 17.6674 2.33265C18.2775 2.94284 18.2775 3.93216 17.6674 4.54235L8.81849 13.3912C8.37792 13.8318 7.83453 14.1556 7.23741 14.3335L5 15L5.66648 12.7626C5.84435 12.1655 6.1682 11.6221 6.60877 11.1815L14.0514 3.73889ZM14.0514 3.73889L16.25 5.93749M15 11.6667V15.625C15 16.6605 14.1605 17.5 13.125 17.5H4.375C3.33947 17.5 2.5 16.6605 2.5 15.625V6.87499C2.5 5.83946 3.33947 4.99999 4.375 4.99999H8.33333" stroke="#596372" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -3,13 +3,17 @@
3
3
  <b-card
4
4
  img-top
5
5
  class="mb-2 screenbuilder-template-card"
6
- @click="showDetails"
6
+ @click="toggleDetails"
7
7
  >
8
8
  <div
9
9
  v-if="thumbnail"
10
10
  class="thumbnail-container thumbnail-image-container"
11
11
  >
12
- <img class="thumbnail-image" :src="thumbnail" :alt="`${template.name}`"/>
12
+ <img
13
+ class="thumbnail-image"
14
+ :src="thumbnail"
15
+ :alt="`${template.name}`"
16
+ />
13
17
  </div>
14
18
  <div
15
19
  v-else
@@ -17,25 +21,31 @@
17
21
  >
18
22
  <i class="p-4 fas fa-palette thumbnail-icon"></i>
19
23
  </div>
20
- <hr class="card-divider">
24
+ <hr class="card-divider" />
21
25
  <b-card-body class="p-1">
22
26
  <div class="template-details">
23
27
  <span class="template-name d-block pt-1">{{ template.name }}</span>
24
- <span class="template-description d-block">{{ template.description }}</span>
28
+ <span class="template-description d-block">{{
29
+ truncateText(template.description, 100)
30
+ }}</span>
25
31
  </div>
26
- <b-collapse v-model="showApplyOptions">
27
- <b-form-checkbox-group
28
- class="apply-options-group p-2"
29
- v-model="selected"
30
- name="apply-options"
31
- >
32
+ <b-collapse v-model="isApplyOptionsActive">
33
+ <b-form-checkbox-group
34
+ v-model="selected"
35
+ class="apply-options-group p-2"
36
+ name="apply-options"
37
+ >
32
38
  <div class="row row-cols-3 icons-row">
33
39
  <div
34
40
  v-for="option in applyOptions"
35
41
  :key="option.value"
36
42
  class="col apply-options-container d-flex align-items-baseline flex-column"
37
43
  >
38
- <div class="icon-container">
44
+ <div
45
+ class="icon-container"
46
+ :class="{ selected: selected.includes(option.value) }"
47
+ @click.stop="toggleOption(option.value)"
48
+ >
39
49
  <div v-if="option.value === 'CSS'">
40
50
  <css-icon />
41
51
  </div>
@@ -43,135 +53,178 @@
43
53
  <i :class="option.icon"></i>
44
54
  </div>
45
55
  </div>
46
- <b-form-checkbox
47
- class="option-checkbox"
48
- :value="option.value"
49
- >
56
+ <b-form-checkbox class="option-checkbox" :value="option.value">
50
57
  {{ option.text }}
51
58
  </b-form-checkbox>
52
59
  </div>
53
60
  </div>
54
- </b-form-checkbox-group>
55
- <hr class="bottom-card-divider">
56
- <div class="apply-btn-container d-flex justify-content-end">
57
- <button
58
- type="button"
59
- size="sm"
60
- class="btn btn-outline-secondary card-btn"
61
- @click="onCancel"
62
- >
63
- {{ $t("Cancel") }}
64
- </button>
65
- <button
66
- :disabled="!selected.length"
67
- type="button"
68
- size="sm"
69
- class="btn btn-primary ml-2 card-btn"
70
- @click="applyTemplate"
71
- >
72
- {{ $t("Apply") }}
73
- </button>
74
- </div>
61
+ </b-form-checkbox-group>
62
+ <hr class="bottom-card-divider" />
63
+ <div class="apply-btn-container d-flex justify-content-end">
64
+ <button
65
+ type="button"
66
+ size="sm"
67
+ class="btn btn-outline-secondary card-btn"
68
+ @click.stop="onCancel"
69
+ >
70
+ {{ $t("Cancel") }}
71
+ </button>
72
+ <button
73
+ :disabled="!selected.length"
74
+ type="button"
75
+ size="sm"
76
+ class="btn btn-primary ml-2 card-btn"
77
+ @click.stop="applyTemplate"
78
+ >
79
+ {{ $t("Apply") }}
80
+ </button>
81
+ </div>
75
82
  </b-collapse>
76
83
  </b-card-body>
77
84
  </b-card>
78
-
79
85
  </div>
80
86
  </template>
81
87
 
82
88
  <script>
83
- import CssIcon from './CssIcon.vue';
89
+ import CssIcon from "./CssIcon.vue";
84
90
 
85
91
  export default {
86
92
  components: {
87
- CssIcon,
93
+ CssIcon
88
94
  },
89
95
  mixins: [],
90
- props: ['template', 'screenId', 'currentScreenPage'],
96
+ props: {
97
+ template: {
98
+ type: Object,
99
+ required: true
100
+ },
101
+ screenId: {
102
+ type: Number,
103
+ required: true
104
+ },
105
+ currentScreenPage: {
106
+ type: Number,
107
+ default: 0
108
+ },
109
+ activeTemplateId: {
110
+ type: Number,
111
+ default: 0
112
+ }
113
+ },
91
114
  data() {
92
115
  return {
93
- showApplyOptions: false,
116
+ isApplyOptionsActive: false,
94
117
  selected: [],
95
118
  applyOptions: [
96
- { text: 'CSS', value: 'CSS' },
97
- { text: 'Fields', value: 'Fields', icon: 'fp-fields-icon' },
98
- { text: 'Layout', value: 'Layout', icon: 'fp-layout-icon' },
99
- ],
119
+ { text: "CSS", value: "CSS" },
120
+ { text: "Fields", value: "Fields", icon: "fp-fields-icon" },
121
+ { text: "Layout", value: "Layout", icon: "fp-layout-icon" }
122
+ ]
100
123
  };
101
124
  },
102
125
  computed: {
103
126
  thumbnail() {
104
- if (this.template?.template_media && this.template.template_media.length > 0) {
127
+ if (
128
+ this.template?.template_media &&
129
+ this.template.template_media.length > 0
130
+ ) {
105
131
  return this.template.template_media[0].url;
106
- } else if (this.template?.template_media?.thumbnail?.url) {
107
- return this.template?.template_media.thumbnail.url
132
+ }
133
+ if (this.template?.template_media?.thumbnail?.url) {
134
+ return this.template?.template_media.thumbnail.url;
108
135
  }
109
136
  return null;
110
- },
137
+ }
111
138
  },
112
- mounted() {
139
+ watch: {
140
+ activeTemplateId(newVal) {
141
+ this.isApplyOptionsActive = newVal === this.template.id;
142
+ }
113
143
  },
114
144
  methods: {
115
- showDetails() {
116
- this.showApplyOptions = !this.showApplyOptions;
145
+ toggleDetails() {
146
+ this.$emit("toggle-active", this.template.id);
117
147
  },
118
148
  applyTemplate() {
119
149
  ProcessMaker.apiClient
120
150
  .post(`/template/screen/${this.template.id}/apply`, {
121
151
  screenId: this.screenId,
122
152
  templateOptions: this.selected,
123
- currentScreenPage: this.currentScreenPage,
153
+ currentScreenPage: this.currentScreenPage
124
154
  })
125
- .then((response) => {
126
- ProcessMaker.alert(this.$t("The template options have been applied."), "success");
155
+ .then(() => {
156
+ ProcessMaker.alert(
157
+ this.$t("The template options have been applied."),
158
+ "success"
159
+ );
127
160
  window.location.reload();
128
161
  })
129
162
  .catch((error) => {
130
- const errorMessage = error.response?.data?.message || error.response?.data?.error || error.message;
163
+ const errorMessage =
164
+ error.response?.data?.message ||
165
+ error.response?.data?.error ||
166
+ error.message;
131
167
  ProcessMaker.alert(errorMessage, "danger");
132
168
  });
133
169
  },
134
170
  onCancel() {
135
- this.showApplyOptions = false;
171
+ this.isApplyOptionsActive = false;
136
172
  this.selected = [];
173
+ },
174
+ toggleOption(value) {
175
+ const index = this.selected.indexOf(value);
176
+ if (index === -1) {
177
+ this.selected.push(value);
178
+ } else {
179
+ this.selected.splice(index, 1);
180
+ }
181
+ },
182
+ truncateText(text, limit) {
183
+ if (!text) return "";
184
+ return text.length > limit ? `${text.substring(0, limit)}...` : text;
137
185
  }
138
- },
186
+ }
139
187
  };
140
188
  </script>
141
189
 
142
190
  <style lang="scss" scoped>
143
-
144
- .fp-fields-icon, .fp-layout-icon {
145
- color: #EAF2FF;
191
+ .fp-fields-icon,
192
+ .fp-layout-icon {
193
+ color: #eaf2ff;
146
194
  }
147
195
 
148
196
  .screenbuilder-template-card {
149
197
  width: 225px;
150
198
  margin: 8px;
151
- border: 1px solid #D7DDE5;
199
+ border: 1px solid #d7dde5;
152
200
  border-radius: 8px;
153
- box-shadow: 0px 3px 6px -3px rgb(0, 0, 0, 0.05), 0px 2px 4px -2px rgba(0, 0, 0, 0.05);
201
+ box-shadow: 0px 3px 6px -3px rgb(0, 0, 0, 0.05),
202
+ 0px 2px 4px -2px rgba(0, 0, 0, 0.05);
154
203
  cursor: pointer;
155
204
  }
156
205
 
157
206
  .card-divider {
158
207
  width: 100%;
159
208
  margin: 0px;
160
- background-color: #D7DDE5;
209
+ background-color: #d7dde5;
161
210
  }
162
211
 
163
212
  .thumbnail-container:hover,
164
213
  .thumbnail-container.active {
165
- border-color: #1572C2;
214
+ border-color: #1572c2;
166
215
  cursor: pointer;
167
216
  }
168
217
 
169
218
  .thumbnail-image {
170
219
  width: 100%;
220
+ height: 100%;
221
+ object-fit: cover;
171
222
  border-radius: 8px 8px 0px 0px;
172
223
  }
173
224
 
174
225
  .thumbnail-image-container {
226
+ width: 100%;
227
+ height: 107px;
175
228
  border-radius: 8px;
176
229
  padding: 0px !important;
177
230
  background-size: contain;
@@ -180,7 +233,7 @@ export default {
180
233
  }
181
234
 
182
235
  .thumbnail-icon {
183
- color: #CDDDEE;
236
+ color: #cdddee;
184
237
  font-size: 59px;
185
238
  }
186
239
 
@@ -192,14 +245,14 @@ export default {
192
245
  font-size: 14px;
193
246
  font-weight: 600;
194
247
  line-height: 20px;
195
- color: #2F343B;
248
+ color: #2f343b;
196
249
  }
197
250
 
198
251
  .template-description {
199
252
  font-size: 12.5px;
200
253
  font-weight: 400;
201
254
  line-height: 18px;
202
- color: #4E5663;
255
+ color: #4e5663;
203
256
  }
204
257
 
205
258
  .apply-options-group {
@@ -214,7 +267,7 @@ export default {
214
267
  }
215
268
 
216
269
  .apply-options-container {
217
- padding: 5px;
270
+ padding: 5px;
218
271
  }
219
272
 
220
273
  .apply-options-group i {
@@ -228,7 +281,7 @@ export default {
228
281
  justify-content: center;
229
282
  width: 66px;
230
283
  height: 76px;
231
- border: 0.7px solid #D7DDE5;
284
+ border: 0.7px solid #d7dde5;
232
285
  border-radius: 8px;
233
286
  margin-bottom: 10px;
234
287
  }
@@ -239,7 +292,7 @@ export default {
239
292
 
240
293
  .bottom-card-divider {
241
294
  width: 90%;
242
- background-color: #E9ECF1;
295
+ background-color: #e9ecf1;
243
296
  margin-top: 0px;
244
297
  }
245
298
 
@@ -253,5 +306,4 @@ export default {
253
306
  border-radius: 8px;
254
307
  padding: 5px 10px;
255
308
  }
256
-
257
- </style>
309
+ </style>