Skip to content

Commit

Permalink
Release 5.8.18
Browse files Browse the repository at this point in the history
### Changelog:
* Feature(frontend): Set `inputmode` in `TagsSelector`.
* Fix(frontend): `TagsSelector` enter button was not visible on phones.
* Fix(frontend): Country code selector in phone field.
* Fix(frontend): Fk field focus inside modal.
* Fix(frontend): Invalid value in number field.

Closes: vst/vst-utils#618+
Closes: vst/vst-utils#619+
Closes: vst/vst-utils#621+

See merge request vst/vst-utils!619
  • Loading branch information
onegreyonewhite committed Dec 11, 2023
2 parents c860660 + f6bf556 commit 8817be5
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 4 deletions.
10 changes: 9 additions & 1 deletion frontend_src/vstutils/components/TagsSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
</button>
{{ item }}
</li>
<input ref="input" class="field" type="text" @keyup.enter="add($refs.input.value)" />
<input
ref="input"
class="field"
type="text"
enterkeyhint="enter"
:inputmode="inputmode"
@keyup.enter="add($refs.input.value)"
/>
</ul>
</template>

Expand All @@ -24,6 +31,7 @@
value: { type: Array, default: () => [] },
unique: { type: Boolean, default: false },
validator: { type: Function, default: (value) => value || undefined },
inputmode: { type: String, default: 'text' },
});
const emit = defineEmits(['change']);
Expand Down
2 changes: 2 additions & 0 deletions frontend_src/vstutils/fields/array/custom/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const NumberArrayFieldEdit = defineComponent({
data() {
return {
itemsValidator: validateNumber,
inputmode: 'decimal',
};
},
});
Expand All @@ -41,6 +42,7 @@ export const IntegerArrayFieldEdit = defineComponent({
data() {
return {
itemsValidator: validateInteger,
inputmode: 'numeric',
};
},
});
Expand Down
2 changes: 2 additions & 0 deletions frontend_src/vstutils/fields/array/custom/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const StringArrayFieldEdit = defineComponent({
data() {
return {
itemsValidator: undefined,
inputmode: undefined,
};
},
render() {
Expand All @@ -31,6 +32,7 @@ export const StringArrayFieldEdit = defineComponent({
value: this.value || [],
unique: this.field.uniqueItems,
validator: this.itemsValidator,
inputmode: this.inputmode,
},
on: { change: (items: unknown[]) => this.$emit('set-value', items) },
class: 'tags-selector',
Expand Down
4 changes: 4 additions & 0 deletions frontend_src/vstutils/fields/fk/fk/FKFieldContentEditable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
$(this.selectEl!).off().select2('destroy');
},
methods: {
getSelectContainer() {
return this.$el;
},
/**
* Method, that mounts select2 to current field's select.
*/
Expand All @@ -66,6 +69,7 @@
},
allowClear: this.field.nullable,
placeholder: { id: undefined, text: '' },
dropdownParent: $(this.getSelectContainer()),
})
.on('change', () => {
// @ts-expect-error Select2 has no types
Expand Down
2 changes: 1 addition & 1 deletion frontend_src/vstutils/fields/numbers/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const NumberFieldContentMixin = {
if (this.field.isValueValid(value)) {
this.$emit('set-value', value);
} else {
this.$refs.input.value = this.value;
this.$refs.input.value = this.value ?? '';
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
</div>
<component
:is="countryCodeField.component"
:is="countryCodeField.getComponent()"
class="code-selector"
:field="countryCodeField"
:data="{ [countryCodeField.name]: countryCode }"
Expand Down
30 changes: 30 additions & 0 deletions frontend_src/vstutils/fields/text/__tests__/phone-field.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect, test, describe } from '@jest/globals';
import { createApp, createSchema, mount } from '@/unittests';

describe('PhoneField', () => {
test('country code selector is rendered', async () => {
const app = await createApp({
schema: createSchema(),
});

const phoneField = app.fieldsResolver.resolveField({
name: 'phone',
type: 'string',
format: 'phone',
});

const wrapper = mount({
template: '<PhoneField :field="field" :data="{}" type="edit" />',
components: {
PhoneField: phoneField.getComponent(),
},
setup() {
return {
field: phoneField,
};
},
});

expect(wrapper.find('select').exists()).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion vstutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# pylint: disable=django-not-available
__version__: str = '5.8.17'
__version__: str = '5.8.18'

0 comments on commit 8817be5

Please sign in to comment.