toggle-components-library 1.10.1
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/README.md +24 -0
- package/babel.config.js +5 -0
- package/dist/demo.html +10 -0
- package/dist/img/add_circle.7c6b29c6.svg +29 -0
- package/dist/img/arrow-left-blue-hover.5b0a1e54.svg +32 -0
- package/dist/img/arrow-left-blue.1e5404dd.svg +32 -0
- package/dist/img/arrow-right-blue-hover.b800a882.svg +32 -0
- package/dist/img/arrow-right-blue.fbc83729.svg +32 -0
- package/dist/img/arrow_down.787e1a8b.svg +28 -0
- package/dist/img/calendar.16f176cd.svg +37 -0
- package/dist/img/card.e1735960.svg +9 -0
- package/dist/img/checkbox_blank.907b325c.svg +6 -0
- package/dist/img/checkbox_checked.3e2d399f.svg +9 -0
- package/dist/img/checkbox_hover.e99ab40c.svg +3 -0
- package/dist/img/checkbox_inactive.b94b6c81.svg +9 -0
- package/dist/img/circle_blank.ab1622db.svg +24 -0
- package/dist/img/clipboard.e483ded3.svg +12 -0
- package/dist/img/delete-grey.cf15dcd1.svg +29 -0
- package/dist/img/delete.ee71bb54.svg +29 -0
- package/dist/img/drag_drop.0c778868.svg +14 -0
- package/dist/img/draggable.7493006c.svg +1 -0
- package/dist/img/edit_circle.4f3826d3.svg +34 -0
- package/dist/img/edit_circle_grey.0c96938c.svg +34 -0
- package/dist/img/email.078e944d.svg +7 -0
- package/dist/img/file.f4fb9e5d.svg +9 -0
- package/dist/img/graph.7f2e3985.svg +16 -0
- package/dist/img/grey_cross.2ac5fda1.svg +15 -0
- package/dist/img/info.4b233da4.svg +29 -0
- package/dist/img/megaphone.73161a8a.svg +19 -0
- package/dist/img/orders.51f8963f.svg +29 -0
- package/dist/img/search.db8f673f.svg +25 -0
- package/dist/img/tick-grey.b6d7b16c.svg +12 -0
- package/dist/img/tick.97f35963.svg +12 -0
- package/dist/img/tick_circle.417fd97d.svg +28 -0
- package/dist/img/tick_circle_grey.92b7e747.svg +32 -0
- package/dist/img/upload.9b0f1f1c.svg +30 -0
- package/dist/toggle-components-library.common.js +17714 -0
- package/dist/toggle-components-library.common.js.map +1 -0
- package/dist/toggle-components-library.css +1 -0
- package/dist/toggle-components-library.umd.js +17724 -0
- package/dist/toggle-components-library.umd.js.map +1 -0
- package/dist/toggle-components-library.umd.min.js +9 -0
- package/dist/toggle-components-library.umd.min.js.map +1 -0
- package/package-lock.json +20271 -0
- package/package.json +78 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/assets/ProximaNova-Regular.otf +0 -0
- package/src/assets/icons/add_circle.svg +29 -0
- package/src/assets/icons/arrow-left-blue-hover.svg +32 -0
- package/src/assets/icons/arrow-left-blue.svg +32 -0
- package/src/assets/icons/arrow-right-blue-hover.svg +32 -0
- package/src/assets/icons/arrow-right-blue.svg +32 -0
- package/src/assets/icons/arrow_down.svg +28 -0
- package/src/assets/icons/calendar.svg +37 -0
- package/src/assets/icons/card.svg +9 -0
- package/src/assets/icons/checkbox_blank.svg +6 -0
- package/src/assets/icons/checkbox_checked.svg +9 -0
- package/src/assets/icons/checkbox_hover.svg +3 -0
- package/src/assets/icons/checkbox_inactive.svg +9 -0
- package/src/assets/icons/circle_blank.svg +24 -0
- package/src/assets/icons/clipboard.svg +12 -0
- package/src/assets/icons/delete-grey.svg +29 -0
- package/src/assets/icons/delete.svg +29 -0
- package/src/assets/icons/drag.svg +15 -0
- package/src/assets/icons/drag_drop.svg +14 -0
- package/src/assets/icons/draggable.svg +1 -0
- package/src/assets/icons/draggable.textClipping +0 -0
- package/src/assets/icons/edit_circle.svg +34 -0
- package/src/assets/icons/edit_circle_grey.svg +34 -0
- package/src/assets/icons/email.svg +7 -0
- package/src/assets/icons/file.svg +9 -0
- package/src/assets/icons/graph.svg +16 -0
- package/src/assets/icons/grey_cross.svg +15 -0
- package/src/assets/icons/info.svg +29 -0
- package/src/assets/icons/megaphone.svg +19 -0
- package/src/assets/icons/orders.svg +29 -0
- package/src/assets/icons/search.svg +25 -0
- package/src/assets/icons/tick-grey.svg +12 -0
- package/src/assets/icons/tick.svg +12 -0
- package/src/assets/icons/tick_circle.svg +28 -0
- package/src/assets/icons/tick_circle_grey.svg +32 -0
- package/src/assets/icons/upload.svg +30 -0
- package/src/assets/img/airship.svg +42 -0
- package/src/assets/img/toggle.svg +1 -0
- package/src/assets/logo.png +0 -0
- package/src/components/badges/ToggleBadge.vue +23 -0
- package/src/components/breadcrumb/ToggleBreadCrumb.vue +43 -0
- package/src/components/buttons/ToggleButton.vue +88 -0
- package/src/components/buttons/ToggleFeatureButton.vue +68 -0
- package/src/components/elements/ToggleLineBreak.vue +9 -0
- package/src/components/forms/ToggleColourPicker.vue +192 -0
- package/src/components/forms/ToggleDatePicker.vue +168 -0
- package/src/components/forms/ToggleDateRangePicker.vue +208 -0
- package/src/components/forms/ToggleInputCheckbox.vue +74 -0
- package/src/components/forms/ToggleInputCheckboxContainer.vue +65 -0
- package/src/components/forms/ToggleInputCheckboxInline.vue +74 -0
- package/src/components/forms/ToggleInputCrudField.vue +95 -0
- package/src/components/forms/ToggleInputCurrency.vue +198 -0
- package/src/components/forms/ToggleInputFile.vue +101 -0
- package/src/components/forms/ToggleInputGrid.vue +409 -0
- package/src/components/forms/ToggleInputGroup.vue +48 -0
- package/src/components/forms/ToggleInputImage.vue +168 -0
- package/src/components/forms/ToggleInputNumber.vue +164 -0
- package/src/components/forms/ToggleInputPercentage.vue +142 -0
- package/src/components/forms/ToggleInputRadioButtonGroup.vue +81 -0
- package/src/components/forms/ToggleInputRadioButtons.vue +136 -0
- package/src/components/forms/ToggleInputSearch.vue +235 -0
- package/src/components/forms/ToggleInputSelect.vue +109 -0
- package/src/components/forms/ToggleInputText.vue +130 -0
- package/src/components/forms/ToggleInputTextArea.vue +123 -0
- package/src/components/forms/ToggleInputWebsite.vue +163 -0
- package/src/components/forms/ToggleInternationalPhoneInputSelect.vue +166 -0
- package/src/components/loaders/ToggleFillLoader.vue +34 -0
- package/src/components/mixins/mixins.js +48 -0
- package/src/components/modals/ToggleModal.vue +83 -0
- package/src/components/navs/sidenav/ToggleSideNav.vue +45 -0
- package/src/components/navs/sidenav/ToggleSideNavItem.vue +32 -0
- package/src/components/navs/sidenav/ToggleSideSubNav.vue +24 -0
- package/src/components/notifications/ToggleNotifications.vue +93 -0
- package/src/components/tables/TogglePagination.vue +114 -0
- package/src/components/tables/ToggleTable.vue +178 -0
- package/src/components/tables/ToggleTableColumn.vue +3 -0
- package/src/components/tables/ToggleTableRow.vue +5 -0
- package/src/components/text/ToggleHeaderTextLarge.vue +3 -0
- package/src/components/text/ToggleHelperTextSmall.vue +3 -0
- package/src/components/text/ToggleInfoText.vue +3 -0
- package/src/components/text/ToggleTextClipboardCopy.vue +51 -0
- package/src/index.js +105 -0
- package/src/sass/includes/_as_animations.scss +8 -0
- package/src/sass/includes/_as_badges.scss +27 -0
- package/src/sass/includes/_as_breadcrumb.scss +39 -0
- package/src/sass/includes/_as_buttons.scss +235 -0
- package/src/sass/includes/_as_elements.scss +3 -0
- package/src/sass/includes/_as_fonts.scss +12 -0
- package/src/sass/includes/_as_globals.scss +1 -0
- package/src/sass/includes/_as_gridbuilder.scss +136 -0
- package/src/sass/includes/_as_inputs.scss +900 -0
- package/src/sass/includes/_as_loader.scss +37 -0
- package/src/sass/includes/_as_loaders.scss +41 -0
- package/src/sass/includes/_as_modals.scss +83 -0
- package/src/sass/includes/_as_navs.scss +120 -0
- package/src/sass/includes/_as_notifications.scss +30 -0
- package/src/sass/includes/_as_sizes.scss +4 -0
- package/src/sass/includes/_as_table.scss +276 -0
- package/src/sass/includes/_as_text.scss +73 -0
- package/src/sass/includes/_as_variables.scss +49 -0
- package/src/sass/main.scss +20 -0
- package/vue.config.js +8 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<div class="toggle-grid-input-container">
|
|
4
|
+
|
|
5
|
+
<div v-for="(row, rowindex) in inputVal" class="toggle-grid-input-row" :key="rowindex" >
|
|
6
|
+
<div class="toggle-grid-input-row-preview">
|
|
7
|
+
|
|
8
|
+
<div class="toggle-grid-input-row-column" draggable="true" v-on:dragstart="drag(rowindex,columnindex)" v-on:drop="drop(rowindex,columnindex)" v-on:dragover="allowDrop" :style="{width:getColumnWidth(column)+'%'}" v-for="(column, columnindex) in row.layout" :key="columnindex">
|
|
9
|
+
<div class="toggle-grid-input-row-column-content" >
|
|
10
|
+
<slot class="content" name="column" :gridReference="[rowindex,columnindex]" :contentData="row.content[columnindex]"></slot>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="toggle-grid-input-row-remove">
|
|
17
|
+
<ToggleButton
|
|
18
|
+
buttonStyle="mini_delete"
|
|
19
|
+
@click="removeRow(rowindex)"
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<!-- row column layout selector -->
|
|
24
|
+
<div class="toggle-grid-input-column-layout-input">
|
|
25
|
+
<label :class="['toggle-grid-input-column-layout-option']" v-for="(layout, layoutindex) in columnConfigurations" :key="layoutindex">
|
|
26
|
+
<input type="radio" :value="layout.layout" :name="'layout_'+rowindex" v-model="inputVal[rowindex].layout" />
|
|
27
|
+
<div class='toggle-grid-input-column-layout-option-custom-radio'>
|
|
28
|
+
<span class="toggle-grid-input-column-layout-option-column" v-for="(columnWidth, columnwidthindex) in layout.layout" :style="{width:getColumnWidth(columnWidth)+'%'}" :key="columnwidthindex">
|
|
29
|
+
<span></span>
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
32
|
+
</label>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
<div class="toggle-grid-input-add-row" >
|
|
40
|
+
<button
|
|
41
|
+
class="toggle-grid-input-add-row-button"
|
|
42
|
+
buttonStyle="mini_add"
|
|
43
|
+
@click="addRow"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
|
|
52
|
+
import { mixins } from '../mixins/mixins'
|
|
53
|
+
import ToggleButton from '../buttons/ToggleButton.vue';
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
mixins:[mixins],
|
|
58
|
+
components:{ToggleButton},
|
|
59
|
+
props: {
|
|
60
|
+
value: {
|
|
61
|
+
type: [Array]
|
|
62
|
+
},
|
|
63
|
+
type: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: true,
|
|
66
|
+
validator: function (value) {
|
|
67
|
+
return ['text', 'email', 'number', 'password'].indexOf(value) !== -1
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
name: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: "ToggleInputText"
|
|
73
|
+
},
|
|
74
|
+
label: {
|
|
75
|
+
type: String,
|
|
76
|
+
required: false
|
|
77
|
+
},
|
|
78
|
+
placeholder: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false
|
|
81
|
+
},
|
|
82
|
+
autocomplete: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true
|
|
85
|
+
},
|
|
86
|
+
size: {
|
|
87
|
+
type: String,
|
|
88
|
+
validator: function (value) {
|
|
89
|
+
return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
required: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false
|
|
95
|
+
},
|
|
96
|
+
isInvalid: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
errorMessage: {
|
|
101
|
+
type: String,
|
|
102
|
+
required: false
|
|
103
|
+
},
|
|
104
|
+
maxLength:{
|
|
105
|
+
type: Number,
|
|
106
|
+
required:false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
data : function(){
|
|
111
|
+
return {
|
|
112
|
+
draggingIndex:null,
|
|
113
|
+
/*rowModel:[
|
|
114
|
+
{
|
|
115
|
+
layout:[12]
|
|
116
|
+
}
|
|
117
|
+
],*/
|
|
118
|
+
columnConfigurations: [
|
|
119
|
+
{
|
|
120
|
+
layout:[12]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
layout:[4,4,4]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
layout:[6,6]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
layout:[9,3]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
layout:[3,9]
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
created : function(){
|
|
140
|
+
},
|
|
141
|
+
computed: {
|
|
142
|
+
inputVal: {
|
|
143
|
+
get: function (){
|
|
144
|
+
return this.value;
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
set: function (value){
|
|
148
|
+
this.$emit('input', value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
watch:{
|
|
153
|
+
|
|
154
|
+
inputVal: {
|
|
155
|
+
handler: function(newVal){
|
|
156
|
+
for (let rowindex = 0; rowindex < newVal.length; rowindex++) {
|
|
157
|
+
// if a row has more column content than columns, we need to make room
|
|
158
|
+
if(newVal[rowindex].content.length > newVal[rowindex].layout.length)
|
|
159
|
+
{
|
|
160
|
+
this.updateGridLayout();
|
|
161
|
+
}else if(newVal[rowindex].content.length < newVal[rowindex].layout.length){
|
|
162
|
+
// If we've added more columns to a row
|
|
163
|
+
// ensure the content length is always the same as the layout length
|
|
164
|
+
this.inputVal[rowindex].content.length = this.inputVal[rowindex].layout.length;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
deep: true // watches changes within an array of objects
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
},
|
|
175
|
+
methods: {
|
|
176
|
+
|
|
177
|
+
allowDrop(ev) {
|
|
178
|
+
ev.preventDefault();
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Drag handler
|
|
184
|
+
* @param {Number} [row] [row dropped into]
|
|
185
|
+
* @param {Number} [column] [column dropped into]
|
|
186
|
+
* @return Void
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
drag(row, column) {
|
|
190
|
+
this.draggingIndex = [row, column];
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Updates the layout of the grid and content automatically to the most logical position
|
|
196
|
+
* Can be called without params, if no content is being added to the grid
|
|
197
|
+
*
|
|
198
|
+
* @param {Number} [row] [the row content is to be added to ]
|
|
199
|
+
* @param {Number} [column] [the column content is to be added to ]
|
|
200
|
+
* @param {Object} [dropped_content] Content to add to the given grid reference
|
|
201
|
+
*/
|
|
202
|
+
updateGridLayout(row, column, dropped_content)
|
|
203
|
+
{
|
|
204
|
+
// if row is undefined, we're not adding a new column
|
|
205
|
+
let built_content = this.buildContentArray(row, column, dropped_content);
|
|
206
|
+
this.setGridContent(built_content.column_array);
|
|
207
|
+
// this.removeEmptyRows();
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
/*
|
|
212
|
+
* Returns the grid index of a column if columns are numbered left to right
|
|
213
|
+
*
|
|
214
|
+
* @param {Number} [column_number] Position of column in an array
|
|
215
|
+
*
|
|
216
|
+
* @return Array [row, column]
|
|
217
|
+
*/
|
|
218
|
+
getGridReferenceOfColumn(column_number)
|
|
219
|
+
{
|
|
220
|
+
let column_count = 0;
|
|
221
|
+
for (let rowindex = 0; rowindex < this.inputVal.length; rowindex++) {
|
|
222
|
+
for (let columnindex = 0; columnindex < this.inputVal[rowindex].content.length; columnindex++) {
|
|
223
|
+
if(column_number == column_count)
|
|
224
|
+
return [rowindex, columnindex];
|
|
225
|
+
column_count++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* Remove a row from the grid
|
|
232
|
+
*
|
|
233
|
+
* @param {Number} [row_index] row index
|
|
234
|
+
*
|
|
235
|
+
* @return void
|
|
236
|
+
*/
|
|
237
|
+
removeRow(row_index){
|
|
238
|
+
this.$delete( this.inputVal, row_index);
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
/*
|
|
242
|
+
* Adds the array of content to the grid layout
|
|
243
|
+
*
|
|
244
|
+
* @param {Array} [content] [array of content]
|
|
245
|
+
*
|
|
246
|
+
* @return Void
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
setGridContent(content)
|
|
250
|
+
{
|
|
251
|
+
|
|
252
|
+
// set the new content to the grid layout
|
|
253
|
+
for (let rowindex = 0; rowindex < this.inputVal.length; rowindex++) {
|
|
254
|
+
let old_number_of_columns = this.inputVal[rowindex].content.length;
|
|
255
|
+
this.inputVal[rowindex].content.length = this.inputVal[rowindex].layout.length;
|
|
256
|
+
for (let columnindex = 0; columnindex < this.inputVal[rowindex].content.length; columnindex++) {
|
|
257
|
+
old_number_of_columns--;
|
|
258
|
+
this.$set( this.inputVal[rowindex].content, columnindex, content.shift());
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// If we're reducing the number of columns in a row, remove any of the extra blank columns that were in that row
|
|
262
|
+
while(old_number_of_columns > 0){
|
|
263
|
+
old_number_of_columns--;
|
|
264
|
+
if(!content[0]){
|
|
265
|
+
content.shift();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Add new rows for any fields that no longer fit in the grid
|
|
271
|
+
while(content.length){
|
|
272
|
+
let value = content.shift();
|
|
273
|
+
if(value){
|
|
274
|
+
this.addRow();
|
|
275
|
+
this.$set( this.inputVal[this.inputVal.length-1].content, 0, value);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
/*
|
|
283
|
+
* Build a row agnostic array of content
|
|
284
|
+
* Can be called without params, if no content is being added to the grid
|
|
285
|
+
*
|
|
286
|
+
* @param {Number} [row] [the row content is to be added to ]
|
|
287
|
+
* @param {Number} [column] [the column content is to be added to ]
|
|
288
|
+
* @param {Object} [dropped_content] Content to add to the given grid reference
|
|
289
|
+
*
|
|
290
|
+
* @return { {Array} [column_array] [Array of columns],{Number} [content_inserted_at] [Index of inserted content] }
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
buildContentArray(row, column, dropped_content)
|
|
295
|
+
{
|
|
296
|
+
let column_array = []; // the array to return
|
|
297
|
+
let content_inserted_at = false; // have we reached the index that the new content has been added to?
|
|
298
|
+
let spaceMadeUp = false; // have we managed to make up space for the extra content?
|
|
299
|
+
|
|
300
|
+
for (let rowindex = 0; rowindex < this.inputVal.length; rowindex++) {
|
|
301
|
+
for (let columnindex = 0; columnindex < this.inputVal[rowindex].content.length; columnindex++) {
|
|
302
|
+
|
|
303
|
+
// if we're adding a new column at this grid co-ordinate, add it in here
|
|
304
|
+
if(rowindex == row && columnindex == column){
|
|
305
|
+
column_array.push(dropped_content); // add in our extra index
|
|
306
|
+
content_inserted_at = column_array.length-1;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// if there's a free space after inserting a new grid content, we remove this to compensate for adding one higher up in the grid
|
|
310
|
+
if(content_inserted_at !== false && !this.inputVal[rowindex].content[columnindex] && !spaceMadeUp){
|
|
311
|
+
spaceMadeUp = true;
|
|
312
|
+
}else{
|
|
313
|
+
// the first column in the row doesn't have any content, then don't add to that, so that content always left aligns by default
|
|
314
|
+
column_array.push(this.inputVal[rowindex].content[columnindex]);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return { column_array:column_array, content_inserted_at: content_inserted_at};
|
|
320
|
+
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Checks if a given row index has content set
|
|
326
|
+
*
|
|
327
|
+
* @param {Number} [row_index] [index of row to check]
|
|
328
|
+
* @return Bool
|
|
329
|
+
*/
|
|
330
|
+
rowHasContent(row_index)
|
|
331
|
+
{
|
|
332
|
+
let row_content_found = false;
|
|
333
|
+
for (let columnindex = 0; columnindex < this.inputVal[row_index].content.length; columnindex++)
|
|
334
|
+
if(this.inputVal[row_index].content[columnindex])
|
|
335
|
+
row_content_found = true;
|
|
336
|
+
return row_content_found;
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Removes excess row content. For example if a layout is [3,3,3] and content is
|
|
342
|
+
* [true,false,true,true] then it sets the content to [true, false, true]
|
|
343
|
+
*
|
|
344
|
+
* @return Void
|
|
345
|
+
*/
|
|
346
|
+
removeExcessContent()
|
|
347
|
+
{
|
|
348
|
+
for (let row_index = 0; row_index < this.inputVal.length; row_index++)
|
|
349
|
+
this.inputVal[row_index].content.length = this.inputVal[row_index].layout.length;
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Removes empty rows from the grid
|
|
354
|
+
*
|
|
355
|
+
* @return Void
|
|
356
|
+
*/
|
|
357
|
+
removeEmptyRows()
|
|
358
|
+
{
|
|
359
|
+
this.removeExcessContent();
|
|
360
|
+
for (let rowindex = 0; rowindex < this.inputVal.length; rowindex++)
|
|
361
|
+
if(!this.rowHasContent(rowindex))
|
|
362
|
+
this.inputVal.splice(rowindex, 1);
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Drop content handler
|
|
367
|
+
* @param {Number} [row] [row dropped into]
|
|
368
|
+
* @param {Number} [column] [column dropped into]
|
|
369
|
+
* @return Void
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
drop(row, column) {
|
|
373
|
+
|
|
374
|
+
let dropped_content = this.inputVal[this.draggingIndex[0]].content[this.draggingIndex[1]];
|
|
375
|
+
|
|
376
|
+
this.$set(
|
|
377
|
+
this.inputVal[this.draggingIndex[0]].content,
|
|
378
|
+
this.draggingIndex[1],
|
|
379
|
+
null
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
this.updateGridLayout(row, column, dropped_content);
|
|
383
|
+
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Add a blank row to the grid
|
|
388
|
+
*/
|
|
389
|
+
addRow()
|
|
390
|
+
{
|
|
391
|
+
this.inputVal.push({layout:[12], content:[null]});
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Get a column percentage width
|
|
396
|
+
* @param {Nunber} [columns] [number of columns (out of 12) the column takes up]
|
|
397
|
+
* @returns {number} [percentage width]
|
|
398
|
+
*/
|
|
399
|
+
getColumnWidth(columns)
|
|
400
|
+
{
|
|
401
|
+
return 100/(12/columns);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<ToggleHeaderTextLarge v-if="label">{{label}}</ToggleHeaderTextLarge>
|
|
4
|
+
<div class="toggle-input-group" >
|
|
5
|
+
<slot></slot>
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
|
|
12
|
+
import { mixins } from '../mixins/mixins'
|
|
13
|
+
import ToggleHeaderTextLarge from '../text/ToggleHeaderTextLarge.vue';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
mixins:[mixins],
|
|
17
|
+
props: {
|
|
18
|
+
label: {
|
|
19
|
+
type: [String,Boolean],
|
|
20
|
+
required: false
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
components: {
|
|
25
|
+
|
|
26
|
+
ToggleHeaderTextLarge
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
data : function(){
|
|
31
|
+
return {};
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
created : function(){
|
|
35
|
+
},
|
|
36
|
+
computed: {
|
|
37
|
+
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</script>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<div class="toggle-input-container " :class="{'toggle-input-is-invalid':isInvalid }" v-on:click="focusClosestInput">
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<label
|
|
7
|
+
v-if="label"
|
|
8
|
+
class="toggle-input-label"
|
|
9
|
+
> {{ label }}
|
|
10
|
+
</label>
|
|
11
|
+
<div class="toggle-dropzone-image-holder">
|
|
12
|
+
<div>
|
|
13
|
+
<draggable
|
|
14
|
+
class="toggle-draggable-group"
|
|
15
|
+
tag="ul"
|
|
16
|
+
v-model="inputVal"
|
|
17
|
+
v-bind="dragOptions"
|
|
18
|
+
|
|
19
|
+
>
|
|
20
|
+
<transition-group type="transition" >
|
|
21
|
+
<li
|
|
22
|
+
class="toggle-draggable-group-item toggle-dark-grey"
|
|
23
|
+
v-for="image in images"
|
|
24
|
+
:key="image.id"
|
|
25
|
+
:style="{marginRight:thumbnailWidth / 8 + 'px'}"
|
|
26
|
+
|
|
27
|
+
>
|
|
28
|
+
<div class="toggle-item-img toggle-dark-grey toggle-center"
|
|
29
|
+
:style="{ background: `rgb(243, 237, 237) url(${image.url}) no-repeat center top`,
|
|
30
|
+
height: previewRatio == 'letterbox' ? thumbnailWidth / 2 + 'px': thumbnailWidth+'px',
|
|
31
|
+
width: thumbnailWidth+'px'}"
|
|
32
|
+
>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="toggle-center" :style="{height:'35px',margin:'5px'}">
|
|
35
|
+
<ToggleButton @click="() => removeImage(image.id)" buttonStyle="mini_delete" />
|
|
36
|
+
</div>
|
|
37
|
+
</li>
|
|
38
|
+
</transition-group>
|
|
39
|
+
</draggable>
|
|
40
|
+
</div>
|
|
41
|
+
<div v-if="images.length < maxFiles">
|
|
42
|
+
<div class="toggle-dropzone-container"
|
|
43
|
+
:style="{ height: previewRatio == 'letterbox' ? thumbnailWidth / 2 + 'px': thumbnailWidth+'px',
|
|
44
|
+
width: thumbnailWidth+'px'}">
|
|
45
|
+
<ToggleFillLoader v-if="loading"/>
|
|
46
|
+
<vue-dropzone
|
|
47
|
+
:ref="_uid"
|
|
48
|
+
class="dropzone"
|
|
49
|
+
:id="'dropzone'+_uid"
|
|
50
|
+
:options="dropzoneOptions"
|
|
51
|
+
@vdropzone-file-added="fileAdded"
|
|
52
|
+
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<ToggleHelperTextSmall>{{helperText}}</ToggleHelperTextSmall>
|
|
59
|
+
<label
|
|
60
|
+
class="toggle-input-label-error"
|
|
61
|
+
v-if="isInvalid"
|
|
62
|
+
>
|
|
63
|
+
{{ errorMessage }}
|
|
64
|
+
</label>
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
<script>
|
|
68
|
+
|
|
69
|
+
import { mixins } from '../mixins/mixins'
|
|
70
|
+
import ToggleButton from '../buttons/ToggleButton.vue';
|
|
71
|
+
import ToggleHelperTextSmall from '../text/ToggleHelperTextSmall';
|
|
72
|
+
import ToggleFillLoader from '../loaders/ToggleFillLoader.vue';
|
|
73
|
+
import draggable from "vuedraggable";
|
|
74
|
+
import vue2Dropzone from 'vue2-dropzone';
|
|
75
|
+
import 'vue2-dropzone/dist/vue2Dropzone.min.css'
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
mixins:[mixins],
|
|
79
|
+
props: {
|
|
80
|
+
|
|
81
|
+
thumbnailWidth:{
|
|
82
|
+
type:Number,
|
|
83
|
+
default:100
|
|
84
|
+
},
|
|
85
|
+
fileAdded:{ // function to call when file added to dropzone
|
|
86
|
+
|
|
87
|
+
},
|
|
88
|
+
removeImage:{ // function to call when image is removed
|
|
89
|
+
|
|
90
|
+
},
|
|
91
|
+
helperText:{
|
|
92
|
+
type:String
|
|
93
|
+
},
|
|
94
|
+
label: {
|
|
95
|
+
type: String,
|
|
96
|
+
required: false
|
|
97
|
+
},
|
|
98
|
+
isInvalid: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false
|
|
101
|
+
},
|
|
102
|
+
errorMessage: {
|
|
103
|
+
type: String,
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
dropzoneOptions:{
|
|
107
|
+
type: Object,
|
|
108
|
+
required:true
|
|
109
|
+
},
|
|
110
|
+
loading:{
|
|
111
|
+
type:Boolean,
|
|
112
|
+
default:false
|
|
113
|
+
},
|
|
114
|
+
images:{
|
|
115
|
+
type:Array,
|
|
116
|
+
required:true
|
|
117
|
+
},
|
|
118
|
+
maxFiles:{
|
|
119
|
+
type:Number,
|
|
120
|
+
default:5
|
|
121
|
+
},
|
|
122
|
+
previewRatio:{
|
|
123
|
+
type:String,
|
|
124
|
+
default:'letterbox'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
components: {
|
|
129
|
+
vueDropzone: vue2Dropzone,
|
|
130
|
+
ToggleButton,
|
|
131
|
+
ToggleFillLoader,
|
|
132
|
+
draggable,
|
|
133
|
+
ToggleHelperTextSmall
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
created : function(){
|
|
138
|
+
},
|
|
139
|
+
computed: {
|
|
140
|
+
dragOptions() {
|
|
141
|
+
return {
|
|
142
|
+
animation: 200,
|
|
143
|
+
group: "images",
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
inputVal: {
|
|
147
|
+
get: function (){
|
|
148
|
+
return this.images;
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
set: function (images){
|
|
152
|
+
this.$emit('orderChanged', images);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
methods: {
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
</script>
|
|
165
|
+
<style lang="scss">
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
</style>
|