pui9-components 2.0.8 → 3.0.0
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/dist/pui9-components.common.js +5300 -22115
- package/dist/pui9-components.css +3 -6
- package/package-lock.json +1 -141
- package/package.json +1 -5
- package/src/App.vue +0 -117
- package/src/components/PuiAutocomplete.vue +0 -196
- package/src/components/PuiCauDialog.vue +0 -192
- package/src/components/PuiCheckbox.vue +0 -126
- package/src/components/PuiCodeEditor.vue +0 -124
- package/src/components/PuiDateField.vue +0 -1043
- package/src/components/PuiField.vue +0 -30
- package/src/components/PuiFieldSet.vue +0 -27
- package/src/components/PuiFileUpload.vue +0 -275
- package/src/components/PuiFileUploadGroup.vue +0 -241
- package/src/components/PuiFilter.vue +0 -104
- package/src/components/PuiFilterGroup.vue +0 -291
- package/src/components/PuiFilterRule.vue +0 -683
- package/src/components/PuiFormFooter.vue +0 -48
- package/src/components/PuiFormFooterBtns.vue +0 -118
- package/src/components/PuiFormHeader.vue +0 -25
- package/src/components/PuiFormLoading.vue +0 -14
- package/src/components/PuiFormMiniAudit.vue +0 -53
- package/src/components/PuiFormTooltip.vue +0 -50
- package/src/components/PuiMasterDetail.vue +0 -103
- package/src/components/PuiModalDialog.vue +0 -91
- package/src/components/PuiModalDialogForm.vue +0 -209
- package/src/components/PuiMultiSelect.vue +0 -636
- package/src/components/PuiNumberField.vue +0 -434
- package/src/components/PuiPasswordField.vue +0 -105
- package/src/components/PuiRadioGroup.vue +0 -105
- package/src/components/PuiRichTextEditor.vue +0 -116
- package/src/components/PuiSelect.vue +0 -1675
- package/src/components/PuiSelectDetailDialog.vue +0 -113
- package/src/components/PuiSelectTextService.vue +0 -61
- package/src/components/PuiSelectorList.vue +0 -169
- package/src/components/PuiSort.vue +0 -98
- package/src/components/PuiSpinnerField.vue +0 -464
- package/src/components/PuiSwitch.vue +0 -104
- package/src/components/PuiTextArea.vue +0 -204
- package/src/components/PuiTextField.vue +0 -389
- package/src/dateTimeUtils.js +0 -78
- package/src/index.js +0 -89
- package/src/main.js +0 -34
- package/src/mixins/PuiFormComponentMixin.js +0 -77
- package/src/mixins/PuiSortMixin.js +0 -136
- package/src/mixins/PuiUtilsNumberMixin.js +0 -29
- package/src/plugins/vuetify.js +0 -33
- package/src/tests/TestAutocomplete.vue +0 -138
- package/src/tests/TestCodeEditor.vue +0 -48
- package/src/tests/TestField.vue +0 -22
- package/src/tests/TestFieldSet.vue +0 -30
- package/src/tests/TestInputCheckbox.vue +0 -53
- package/src/tests/TestInputDate.vue +0 -146
- package/src/tests/TestInputNumber.vue +0 -77
- package/src/tests/TestInputRadioGroup.vue +0 -86
- package/src/tests/TestInputSpinner.vue +0 -77
- package/src/tests/TestInputSwitch.vue +0 -52
- package/src/tests/TestInputText.vue +0 -120
- package/src/tests/TestInputTextArea.vue +0 -73
- package/src/tests/TestMultiSelect.vue +0 -127
- package/src/tests/TestPuiForm.vue +0 -68
- package/src/tests/TestRichTextEditor.vue +0 -54
- package/src/tests/unit/PuiCheckbox.spec.js +0 -86
- package/src/tests/unit/PuiTextArea.spec.js +0 -62
- package/src/tests/unit/PuiTextField.spec.js +0 -119
- package/src/tests/unit/index.js +0 -5
- package/src/utils.js +0 -158
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-container>
|
|
3
|
-
<v-card class="pa-4 mt-4">
|
|
4
|
-
<v-layout>
|
|
5
|
-
<v-flex xs12 md6>
|
|
6
|
-
<pui-multi-select
|
|
7
|
-
itemValue="id"
|
|
8
|
-
itemText="name"
|
|
9
|
-
:items="model1.items_all"
|
|
10
|
-
:itemsToSelect="model1.items_selected"
|
|
11
|
-
v-model="model1.items_selected"
|
|
12
|
-
></pui-multi-select>
|
|
13
|
-
</v-flex>
|
|
14
|
-
<v-flex xs12 md6>
|
|
15
|
-
<v-layout wrap>
|
|
16
|
-
<v-flex xs12>
|
|
17
|
-
<b>Todos</b>
|
|
18
|
-
<div>{{ model1.items_all }}</div>
|
|
19
|
-
</v-flex>
|
|
20
|
-
<v-flex xs12>
|
|
21
|
-
<b>Seleccionados</b>
|
|
22
|
-
<div>{{ model1.items_selected }}</div>
|
|
23
|
-
</v-flex>
|
|
24
|
-
</v-layout>
|
|
25
|
-
</v-flex>
|
|
26
|
-
</v-layout>
|
|
27
|
-
</v-card>
|
|
28
|
-
<v-card class="pa-4 mt-4">
|
|
29
|
-
<v-layout>
|
|
30
|
-
<v-flex xs12 md6>
|
|
31
|
-
<pui-multi-select
|
|
32
|
-
:items="model2.items_all"
|
|
33
|
-
:itemsToSelect="model2.items_selected"
|
|
34
|
-
v-model="model2.items_selected"
|
|
35
|
-
:trackItemsToSelect="true"
|
|
36
|
-
:flat="true"
|
|
37
|
-
></pui-multi-select>
|
|
38
|
-
</v-flex>
|
|
39
|
-
<v-flex xs12 md6>
|
|
40
|
-
<v-layout wrap>
|
|
41
|
-
<v-flex xs12>
|
|
42
|
-
<b>Todos</b>
|
|
43
|
-
<div>{{ model2.items_all }}</div>
|
|
44
|
-
</v-flex>
|
|
45
|
-
<v-flex xs12>
|
|
46
|
-
<b>Seleccionados</b>
|
|
47
|
-
<div>{{ model2.items_selected }}</div>
|
|
48
|
-
</v-flex>
|
|
49
|
-
</v-layout>
|
|
50
|
-
</v-flex>
|
|
51
|
-
</v-layout>
|
|
52
|
-
</v-card>
|
|
53
|
-
<v-card class="pa-4 mt-4">
|
|
54
|
-
<v-layout>
|
|
55
|
-
<v-flex xs12 md6>
|
|
56
|
-
<pui-multi-select
|
|
57
|
-
:items="model3.items_all"
|
|
58
|
-
:itemsToSelect="model3.items_selected"
|
|
59
|
-
v-model="model3.items_selected"
|
|
60
|
-
disabled
|
|
61
|
-
></pui-multi-select>
|
|
62
|
-
</v-flex>
|
|
63
|
-
<v-flex xs12 md6>
|
|
64
|
-
<v-layout wrap>
|
|
65
|
-
<v-flex xs12>
|
|
66
|
-
<b>Todos</b>
|
|
67
|
-
<div>{{ model3.items_all }}</div>
|
|
68
|
-
</v-flex>
|
|
69
|
-
<v-flex xs12>
|
|
70
|
-
<b>Seleccionados</b>
|
|
71
|
-
<div>{{ model3.items_selected }}</div>
|
|
72
|
-
</v-flex>
|
|
73
|
-
</v-layout>
|
|
74
|
-
</v-flex>
|
|
75
|
-
</v-layout>
|
|
76
|
-
</v-card>
|
|
77
|
-
</v-container>
|
|
78
|
-
</template>
|
|
79
|
-
|
|
80
|
-
<script>
|
|
81
|
-
import PuiMultiSelect from '@/components/PuiMultiSelect';
|
|
82
|
-
|
|
83
|
-
export default {
|
|
84
|
-
name: 'TestMultiSelect',
|
|
85
|
-
components: { PuiMultiSelect },
|
|
86
|
-
data() {
|
|
87
|
-
return {
|
|
88
|
-
model1: {
|
|
89
|
-
items_selected: [{ name: 'sergi', id: 'sergi' }],
|
|
90
|
-
items_all: [
|
|
91
|
-
{ name: 'sergi', id: 'sergi' },
|
|
92
|
-
{ name: 'vicent', id: 'vicent' },
|
|
93
|
-
{ name: 'marc', id: 'marc' },
|
|
94
|
-
{ name: 'miquel', id: 'miquel' },
|
|
95
|
-
{ name: 'cesar', id: 'cesar' },
|
|
96
|
-
{ name: 'victor', id: 'victor' },
|
|
97
|
-
{ name: 'amelia', id: 'amelia' },
|
|
98
|
-
{ name: 'natxo', id: 'natxo' }
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
model2: {
|
|
102
|
-
items_selected: [{ text: 'ESTEBAN', value: 'ESTEBAN' }],
|
|
103
|
-
items_all: [
|
|
104
|
-
{ text: 'JOSE', value: 'JOSE' },
|
|
105
|
-
{ text: 'JUAN', value: 'JUAN' },
|
|
106
|
-
{ text: 'ANDRES', value: 'ANDRES' },
|
|
107
|
-
{ text: 'ESTEBAN', value: 'ESTEBAN' }
|
|
108
|
-
]
|
|
109
|
-
},
|
|
110
|
-
model3: {
|
|
111
|
-
items_selected: [{ text: 'ANDRES', value: 'ANDRES' }],
|
|
112
|
-
items_all: []
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
created() {
|
|
117
|
-
setTimeout(() => {
|
|
118
|
-
this.model3.items_all = [
|
|
119
|
-
{ text: 'JOSE', value: 'JOSE' },
|
|
120
|
-
{ text: 'JUAN', value: 'JUAN' },
|
|
121
|
-
{ text: 'ANDRES', value: 'ANDRES' },
|
|
122
|
-
{ text: 'ESTEBAN', value: 'ESTEBAN' }
|
|
123
|
-
];
|
|
124
|
-
}, 4000);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
</script>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="pui-form">
|
|
3
|
-
<pui-form-header :showHeader="true" v-if="modelLoaded">
|
|
4
|
-
<div class="puiformheader">
|
|
5
|
-
<v-layout wrap>
|
|
6
|
-
<v-flex xs12>
|
|
7
|
-
<label>Here goes the header content</label>
|
|
8
|
-
</v-flex>
|
|
9
|
-
</v-layout>
|
|
10
|
-
</div>
|
|
11
|
-
</pui-form-header>
|
|
12
|
-
|
|
13
|
-
<v-form class="mb-4 pb-4" ref="form" v-model="valid" lazy-validation v-if="modelLoaded">
|
|
14
|
-
<v-layout wrap class="pui-form-layout">
|
|
15
|
-
<v-flex xs12>
|
|
16
|
-
<label>Here goes the form content</label>
|
|
17
|
-
</v-flex>
|
|
18
|
-
<pui-form-mini-audit class="pl-2" :model="model"></pui-form-mini-audit>
|
|
19
|
-
</v-layout>
|
|
20
|
-
<pui-form-footer>
|
|
21
|
-
<pui-form-footer-btns :formDisabled="formDisabled" :save="save" :back="back"></pui-form-footer-btns>
|
|
22
|
-
</pui-form-footer>
|
|
23
|
-
</v-form>
|
|
24
|
-
<pui-form-loading v-else></pui-form-loading>
|
|
25
|
-
</div>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
import PuiFormHeader from '@/components/PuiFormHeader';
|
|
30
|
-
import PuiFormFooter from '@/components/PuiFormFooter';
|
|
31
|
-
import PuiFormFooterBtns from '@/components/PuiFormFooterBtns';
|
|
32
|
-
import PuiFormMiniAudit from '@/components/PuiFormMiniAudit';
|
|
33
|
-
import PuiFormLoading from '@/components/PuiFormLoading';
|
|
34
|
-
|
|
35
|
-
export default {
|
|
36
|
-
components: { PuiFormHeader, PuiFormFooter, PuiFormFooterBtns, PuiFormMiniAudit, PuiFormLoading },
|
|
37
|
-
data() {
|
|
38
|
-
return {
|
|
39
|
-
modelLoaded: false,
|
|
40
|
-
valid: true,
|
|
41
|
-
formDisabled: false,
|
|
42
|
-
model: {
|
|
43
|
-
usralta: 'Pepe Hortulano',
|
|
44
|
-
fecalta: '2019-09-05T10:26:49.441Z',
|
|
45
|
-
usrmodif: 'Elsa Abril',
|
|
46
|
-
fecmodif: '2019-09-08T12:18:43.441Z'
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
created() {
|
|
51
|
-
this.lazyLoadTest();
|
|
52
|
-
this.$store.commit('puiMenuHideMenu', true);
|
|
53
|
-
},
|
|
54
|
-
methods: {
|
|
55
|
-
lazyLoadTest() {
|
|
56
|
-
setTimeout(() => {
|
|
57
|
-
this.modelLoaded = true;
|
|
58
|
-
}, 3000);
|
|
59
|
-
},
|
|
60
|
-
save() {
|
|
61
|
-
console.log('Save clicked!');
|
|
62
|
-
},
|
|
63
|
-
back() {
|
|
64
|
-
console.log('Back clicked!');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
</script>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-container>
|
|
3
|
-
<v-flex xs12>
|
|
4
|
-
<v-card class="pa-4 mt-4">
|
|
5
|
-
<h2 class="mb-4">Rich Text Editor</h2>
|
|
6
|
-
<pui-rich-text-editor id="editor1" :label="label" v-model="model1"></pui-rich-text-editor>
|
|
7
|
-
</v-card>
|
|
8
|
-
<v-card class="pa-4 mt-4">
|
|
9
|
-
<h2 class="mb-4">Code Editor in Form</h2>
|
|
10
|
-
|
|
11
|
-
<v-form ref="form" v-model="valid" lazy-validation v-if="modelLoaded">
|
|
12
|
-
<pui-rich-text-editor
|
|
13
|
-
id="editor2"
|
|
14
|
-
:label="label"
|
|
15
|
-
v-model="model1"
|
|
16
|
-
required
|
|
17
|
-
:validationErrors="formValidationErrors"
|
|
18
|
-
></pui-rich-text-editor>
|
|
19
|
-
<v-btn depressed color="secondary" class="elevation-0" @click.native="save(false)">
|
|
20
|
-
Save
|
|
21
|
-
</v-btn>
|
|
22
|
-
</v-form>
|
|
23
|
-
</v-card>
|
|
24
|
-
</v-flex>
|
|
25
|
-
</v-container>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
import PuiRichTextEditor from '@/components/PuiRichTextEditor';
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
name: 'TestRichTextEditor',
|
|
33
|
-
components: { PuiRichTextEditor },
|
|
34
|
-
data() {
|
|
35
|
-
return {
|
|
36
|
-
label: 'Etiqueta editor de texto enriquecido',
|
|
37
|
-
model1: 'Este texto se está editando con el componente PuiRichTextEditor',
|
|
38
|
-
valid: true,
|
|
39
|
-
modelLoaded: true,
|
|
40
|
-
formValidationErrors: false
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
methods: {
|
|
44
|
-
save() {
|
|
45
|
-
this.formValidationErrors = false;
|
|
46
|
-
if (this.$refs.form && this.$refs.form.validate && !this.$refs.form.validate()) {
|
|
47
|
-
this.formValidationErrors = true;
|
|
48
|
-
console.log('Hay errores de validación en el formulario');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
</script>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createLocalVue, mount } from '@vue/test-utils';
|
|
2
|
-
import PuiCheckbox from '@/components/PuiCheckbox.vue';
|
|
3
|
-
|
|
4
|
-
import Vuex from 'vuex';
|
|
5
|
-
import Vuetify from 'vuetify';
|
|
6
|
-
|
|
7
|
-
const localVue = createLocalVue();
|
|
8
|
-
localVue.use(Vuex);
|
|
9
|
-
|
|
10
|
-
const vuetify = new Vuetify();
|
|
11
|
-
|
|
12
|
-
const id = 'puicheckbox';
|
|
13
|
-
const label = 'PuiCheckbox label';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
describe('PuiCheckbox.vue', () => {
|
|
17
|
-
|
|
18
|
-
const getters = {
|
|
19
|
-
isMobile: () => false
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const store = new Vuex.Store({ getters });
|
|
23
|
-
|
|
24
|
-
const createWrapper = (propsData) => {
|
|
25
|
-
return mount(PuiCheckbox, {
|
|
26
|
-
localVue,
|
|
27
|
-
store,
|
|
28
|
-
vuetify,
|
|
29
|
-
propsData
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
it('Should render pui-checkbox with label', () => {
|
|
34
|
-
const wrapper = createWrapper({
|
|
35
|
-
id,
|
|
36
|
-
label,
|
|
37
|
-
value: true
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
let element = wrapper.find('div[id="puicheckbox"] label');
|
|
41
|
-
expect(element.exists()).toBe(true);
|
|
42
|
-
expect(element.text()).toContain('PuiCheckbox label');
|
|
43
|
-
expect(element.classes('v-label--required')).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('Should render pui-checkbox with required CSS class', () => {
|
|
47
|
-
const wrapper = createWrapper({
|
|
48
|
-
id,
|
|
49
|
-
label,
|
|
50
|
-
value: true,
|
|
51
|
-
required: true
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
let element = wrapper.find('div[id="puicheckbox"]');
|
|
55
|
-
expect(element.exists()).toBe(true);
|
|
56
|
-
expect(element.classes('v-input--checkbox--required')).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('Should render pui-checkbox with 1|0 values', () => {
|
|
60
|
-
const wrapper = createWrapper({
|
|
61
|
-
id,
|
|
62
|
-
label,
|
|
63
|
-
value: 1,
|
|
64
|
-
trueValue: 1,
|
|
65
|
-
falseValue: 0
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
let element = wrapper.find('div[id="puicheckbox"] input');
|
|
69
|
-
expect(element.exists()).toBe(true);
|
|
70
|
-
expect(element.element.value).toBe("1");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('Should render pui-checkbox with S|N values', () => {
|
|
74
|
-
const wrapper = createWrapper({
|
|
75
|
-
id,
|
|
76
|
-
label,
|
|
77
|
-
value: "N",
|
|
78
|
-
trueValue: "S",
|
|
79
|
-
falseValue: "N"
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
let element = wrapper.find('div[id="puicheckbox"] input');
|
|
83
|
-
expect(element.exists()).toBe(true);
|
|
84
|
-
expect(element.element.value).toBe("N");
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createLocalVue, mount } from '@vue/test-utils';
|
|
2
|
-
import PuiTextArea from '@/components/PuiTextArea.vue';
|
|
3
|
-
|
|
4
|
-
import Vuex from 'vuex';
|
|
5
|
-
import Vuetify from 'vuetify';
|
|
6
|
-
import VueI18n from 'vue-i18n';
|
|
7
|
-
|
|
8
|
-
import enPuiTranslations from '../../../../pui9-translations/translations/en.json';
|
|
9
|
-
import esPuiTranslations from '../../../../pui9-translations/translations/es.json';
|
|
10
|
-
|
|
11
|
-
const localVue = createLocalVue();
|
|
12
|
-
localVue.use(Vuex);
|
|
13
|
-
localVue.use(VueI18n);
|
|
14
|
-
|
|
15
|
-
const vuetify = new Vuetify();
|
|
16
|
-
const i18n = new VueI18n({
|
|
17
|
-
locale: 'es',
|
|
18
|
-
fallbackLocale: 'en',
|
|
19
|
-
messages: { en: enPuiTranslations, es: esPuiTranslations }
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const id = 'puitextarea';
|
|
25
|
-
const label = 'PuiTextArea label';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
describe('PuiTextArea.vue Mobile', () => {
|
|
29
|
-
|
|
30
|
-
const getters = {
|
|
31
|
-
isMobile: () => false
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const store = new Vuex.Store({ getters });
|
|
35
|
-
|
|
36
|
-
const createWrapper = (propsData) => {
|
|
37
|
-
return mount(PuiTextArea, {
|
|
38
|
-
localVue,
|
|
39
|
-
store,
|
|
40
|
-
vuetify,
|
|
41
|
-
i18n,
|
|
42
|
-
propsData
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
it('Should render pui-text-area with label', () => {
|
|
48
|
-
const wrapper = createWrapper({
|
|
49
|
-
id,
|
|
50
|
-
label,
|
|
51
|
-
topLabel: true,
|
|
52
|
-
value: null
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(wrapper.vm.hasLabel).toBe(true);
|
|
56
|
-
|
|
57
|
-
const element = wrapper.find('div[id="puitextarea"] label');
|
|
58
|
-
expect(element.exists()).toBe(true);
|
|
59
|
-
expect(element.text()).toContain('PuiTextArea label');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { createLocalVue, mount } from '@vue/test-utils';
|
|
2
|
-
import PuiTextField from '@/components/PuiTextField.vue';
|
|
3
|
-
|
|
4
|
-
import Vuex from 'vuex';
|
|
5
|
-
import Vuetify from 'vuetify';
|
|
6
|
-
import VueI18n from 'vue-i18n';
|
|
7
|
-
|
|
8
|
-
import enPuiTranslations from '../../../../pui9-translations/translations/en.json';
|
|
9
|
-
import esPuiTranslations from '../../../../pui9-translations/translations/es.json';
|
|
10
|
-
|
|
11
|
-
const localVue = createLocalVue();
|
|
12
|
-
localVue.use(Vuex);
|
|
13
|
-
localVue.use(VueI18n);
|
|
14
|
-
|
|
15
|
-
const vuetify = new Vuetify();
|
|
16
|
-
const i18n = new VueI18n({
|
|
17
|
-
locale: 'es',
|
|
18
|
-
fallbackLocale: 'en',
|
|
19
|
-
messages: { en: enPuiTranslations, es: esPuiTranslations }
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const id = 'puitextfield';
|
|
25
|
-
const label = 'PuiTextField label';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
describe('PuiTextField.vue Desktop', () => {
|
|
29
|
-
|
|
30
|
-
const getters = {
|
|
31
|
-
isMobile: () => false
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const store = new Vuex.Store({ getters });
|
|
35
|
-
|
|
36
|
-
const createWrapper = (propsData) => {
|
|
37
|
-
return mount(PuiTextField, {
|
|
38
|
-
localVue,
|
|
39
|
-
store,
|
|
40
|
-
vuetify,
|
|
41
|
-
i18n,
|
|
42
|
-
propsData
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
it('Should render pui-text-field with label', () => {
|
|
47
|
-
const wrapper = createWrapper({
|
|
48
|
-
id,
|
|
49
|
-
label,
|
|
50
|
-
topLabel: true,
|
|
51
|
-
value: null
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(wrapper.vm.hasLabel).toBe(true);
|
|
55
|
-
|
|
56
|
-
const element = wrapper.find('div[id="puitextfield"] label');
|
|
57
|
-
expect(element.exists()).toBe(true);
|
|
58
|
-
expect(element.text()).toContain('PuiTextField label');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('Should render pui-text-field with required CSS class', () => {
|
|
62
|
-
const wrapper = createWrapper({
|
|
63
|
-
id,
|
|
64
|
-
label,
|
|
65
|
-
topLabel: true,
|
|
66
|
-
value: null,
|
|
67
|
-
required: true
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
let element = wrapper.find('div[id="puitextfield"] label');
|
|
71
|
-
expect(element.classes('v-label--required')).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('Should render pui-text-field, with null value and required attribute', () => {
|
|
75
|
-
const wrapper = createWrapper({
|
|
76
|
-
id,
|
|
77
|
-
label,
|
|
78
|
-
topLabel: true,
|
|
79
|
-
value: null,
|
|
80
|
-
required: true
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
let input = wrapper.find('input[id="puitextfield"]');
|
|
84
|
-
expect(input.exists()).toBe(true);
|
|
85
|
-
expect(input.element.value).toBe('');
|
|
86
|
-
expect(input.element.hasAttribute('required')).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('Should render pui-text-field, with default value and set value', async () => {
|
|
90
|
-
const wrapper = createWrapper({
|
|
91
|
-
id,
|
|
92
|
-
label,
|
|
93
|
-
topLabel: true,
|
|
94
|
-
value: 'PuiTextField value'
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const input = wrapper.find('input[id="puitextfield"]');
|
|
98
|
-
expect(input.exists()).toBe(true);
|
|
99
|
-
expect(input.element.value).toBe('PuiTextField value');
|
|
100
|
-
|
|
101
|
-
await input.setValue('new value');
|
|
102
|
-
expect(input.element.value).toBe('new value');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('Should render pui-text-field, with tooltip', async () => {
|
|
106
|
-
const wrapper = createWrapper({
|
|
107
|
-
id,
|
|
108
|
-
label,
|
|
109
|
-
topLabel: true,
|
|
110
|
-
value: null,
|
|
111
|
-
tooltip: true,
|
|
112
|
-
description: 'Tooltip description'
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
expect(wrapper.vm.showTooltip).toBe(true);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// TODO: test more cases
|
|
119
|
-
});
|
package/src/tests/unit/index.js
DELETED
package/src/utils.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
getPathModelMethodPk: (router, modelName) => {
|
|
3
|
-
var path = router.currentRoute.path;
|
|
4
|
-
var routeTokens = path.split('/');
|
|
5
|
-
var tokens = [];
|
|
6
|
-
|
|
7
|
-
for (let i = 0, length = routeTokens.length; i < length; i++) {
|
|
8
|
-
if (routeTokens[i] !== '') {
|
|
9
|
-
tokens.push(routeTokens[i]);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var position = null;
|
|
14
|
-
for (let i = 0, length = tokens.length; i < length; i++) {
|
|
15
|
-
const token = tokens[i];
|
|
16
|
-
if (token === modelName) {
|
|
17
|
-
position = i;
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (position == null) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var method = tokens[position + 1];
|
|
27
|
-
var bpk = tokens[position + 2];
|
|
28
|
-
var pk = null;
|
|
29
|
-
|
|
30
|
-
if (bpk !== 'new') {
|
|
31
|
-
pk = decodeURIComponent(escape(window.atob(bpk)));
|
|
32
|
-
pk = JSON.parse(pk);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var info = {
|
|
36
|
-
modelName: modelName,
|
|
37
|
-
method: method,
|
|
38
|
-
pk: pk
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var parentTokens = tokens.slice(0, position);
|
|
42
|
-
var parentTokensLength = parentTokens.length;
|
|
43
|
-
var child = info;
|
|
44
|
-
while (parentTokensLength >= 3) {
|
|
45
|
-
var parentPk = parentTokens[parentTokensLength - 1];
|
|
46
|
-
var parentPkJson = decodeURIComponent(escape(window.atob(parentPk)));
|
|
47
|
-
var parentMethod = parentTokens[parentTokensLength - 2];
|
|
48
|
-
var parentModelName = parentTokens[parentTokensLength - 3];
|
|
49
|
-
|
|
50
|
-
if (parentMethod === 'create' || parentMethod === 'update' || parentMethod === 'read' || parentMethod === 'action') {
|
|
51
|
-
child.parent = {
|
|
52
|
-
modelName: parentModelName,
|
|
53
|
-
method: parentMethod,
|
|
54
|
-
pk: JSON.parse(parentPkJson)
|
|
55
|
-
};
|
|
56
|
-
child = child.parent;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
parentTokens = parentTokens.slice(0, parentTokensLength - 3);
|
|
60
|
-
parentTokensLength = parentTokens.length;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return info;
|
|
64
|
-
},
|
|
65
|
-
getComponentOffset: component => {
|
|
66
|
-
var rect = component.getBoundingClientRect();
|
|
67
|
-
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
68
|
-
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
69
|
-
return { top: rect.top + scrollTop, left: rect.left + scrollLeft };
|
|
70
|
-
},
|
|
71
|
-
getModelFromRouter: router => {
|
|
72
|
-
var routeTokens = router.path.split('/');
|
|
73
|
-
var tokens = [];
|
|
74
|
-
|
|
75
|
-
for (let i = 0, length = routeTokens.length; i < length; i++) {
|
|
76
|
-
if (routeTokens[i] && routeTokens[i] !== router.params.pk && routeTokens[i] !== router.params.method) {
|
|
77
|
-
tokens.push(routeTokens[i]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return tokens[tokens.length - 1];
|
|
82
|
-
},
|
|
83
|
-
convertPkStringToPkObject: (model, pkStr) => {
|
|
84
|
-
const splits = pkStr.split("#");
|
|
85
|
-
const pkObj = {};
|
|
86
|
-
var i = 0;
|
|
87
|
-
model.columns.filter(c => c.isPk).forEach(c => {
|
|
88
|
-
pkObj[c.name] = splits[i++];
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return pkObj;
|
|
92
|
-
},
|
|
93
|
-
utf8ToB64: str => {
|
|
94
|
-
if (str) {
|
|
95
|
-
return window.btoa(unescape(encodeURIComponent(str)));
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
b64ToUtf8: str => {
|
|
99
|
-
if (str) {
|
|
100
|
-
return decodeURIComponent(escape(window.atob(str)));
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
getFilenameFromHeaders: headers => {
|
|
104
|
-
const disposition = headers['content-disposition'];
|
|
105
|
-
if (disposition && disposition.indexOf('attachment') !== -1) {
|
|
106
|
-
var filenameRegex = /filename=((['"]).*?\2|[^;\n]*)/;
|
|
107
|
-
var matches = filenameRegex.exec(disposition);
|
|
108
|
-
if (matches != null && matches[1]) {
|
|
109
|
-
return matches[1].replace(/['"]/g, '');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
},
|
|
114
|
-
compressImageFile: (file, fileReaderEvent, maxResolution, quality, compressImageFileCallback) => {
|
|
115
|
-
const MAX_RESOLUTION = maxResolution || 1200;
|
|
116
|
-
const QUALITY = quality === 'low' ? 0.1 : quality === 'medium' ? 0.5 : 1;
|
|
117
|
-
|
|
118
|
-
const img = new window.Image();
|
|
119
|
-
img.src = fileReaderEvent.target.result;
|
|
120
|
-
img.addEventListener('load', () => {
|
|
121
|
-
const canvas = document.createElement('canvas');
|
|
122
|
-
let ctx = canvas.getContext('2d');
|
|
123
|
-
ctx.drawImage(img, 0, 0);
|
|
124
|
-
|
|
125
|
-
// img.width and img.height will contain the original dimensions
|
|
126
|
-
let width = img.width;
|
|
127
|
-
let height = img.height;
|
|
128
|
-
|
|
129
|
-
if (width > height) {
|
|
130
|
-
if (width > MAX_RESOLUTION) {
|
|
131
|
-
height *= MAX_RESOLUTION / width;
|
|
132
|
-
width = MAX_RESOLUTION;
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
if (height > MAX_RESOLUTION) {
|
|
136
|
-
width *= MAX_RESOLUTION / height;
|
|
137
|
-
height = MAX_RESOLUTION;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
canvas.width = width;
|
|
142
|
-
canvas.height = height;
|
|
143
|
-
ctx = canvas.getContext('2d');
|
|
144
|
-
ctx.drawImage(img, 0, 0, width, height);
|
|
145
|
-
canvas.toBlob(
|
|
146
|
-
blob => {
|
|
147
|
-
const newFile = new window.File([blob], file.name, {
|
|
148
|
-
type: file.type,
|
|
149
|
-
lastModified: Date.now()
|
|
150
|
-
});
|
|
151
|
-
compressImageFileCallback(newFile);
|
|
152
|
-
},
|
|
153
|
-
file.type,
|
|
154
|
-
QUALITY
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
};
|