language module
This commit is contained in:
@@ -9,7 +9,7 @@ import registerComponents from '../components/register';
|
||||
import registerFormComponents from '../forms/register';
|
||||
import registerEditorComponents from '../editor/register';
|
||||
import { getRouterConfig, appendRouterGuards } from './router/routerConfig';
|
||||
import { countryPlugin, applicationPlugin, settingsPlugin } from '../modules';
|
||||
import { countryPlugin, applicationPlugin, settingsPlugin, languagePlugin } from '../modules';
|
||||
import { ZeroSchema } from 'zero/schemas';
|
||||
import { ZeroSchemaProp } from './zero';
|
||||
import * as zeroOptions from '../options';
|
||||
@@ -85,6 +85,7 @@ export class ZeroRuntime implements Zero
|
||||
countryPlugin.install(pluginOptions);
|
||||
applicationPlugin.install(pluginOptions);
|
||||
settingsPlugin.install(pluginOptions);
|
||||
languagePlugin.install(pluginOptions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export * from './countries';
|
||||
export * from './applications';
|
||||
export * from './settings';
|
||||
export * from './settings';
|
||||
export * from './languages';
|
||||
@@ -0,0 +1,16 @@
|
||||
import { get, post, put, del, ApiRequestConfig, ApiRequestQuery } from '../../services/request';
|
||||
|
||||
export default {
|
||||
|
||||
getEmpty: (flavor?: string, config?: ApiRequestConfig) => get("languages/empty", { ...config, params: { flavor } }),
|
||||
|
||||
getById: (id: string, changeVector?: string, config?: ApiRequestConfig) => get('languages/' + id, { ...config, params: { changeVector } }),
|
||||
|
||||
getByQuery: (query: ApiRequestQuery, config?: ApiRequestConfig) => get('languages', { ...config, params: { ...query } }),
|
||||
|
||||
create: (model: any, config?: ApiRequestConfig) => post('languages', model, config),
|
||||
|
||||
update: (model: any, config?: ApiRequestConfig) => put('languages/' + model.id, model, config),
|
||||
|
||||
delete: (id: string, config?: ApiRequestConfig) => del('languages/' + id, config),
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import api from './api';
|
||||
import editor from './schemas/editor';
|
||||
import list from './schemas/list';
|
||||
import plugin from './plugin';
|
||||
|
||||
export {
|
||||
api as languageApi,
|
||||
editor as languageSchema,
|
||||
list as languageListSchema,
|
||||
plugin as languagePlugin
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<ui-form ref="form" class="language" v-slot="form" @submit="onSubmit" @load="onLoad" :route="route">
|
||||
<ui-form-header v-model:value="model" prefix="@language.list" title="@language.name" :disabled="disabled" :is-create="!id" :state="form.state" :can-delete="meta.canDelete" @delete="onDelete" />
|
||||
<ui-editor config="languages:edit" v-model="model" :meta="meta" :disabled="disabled">
|
||||
<template v-slot:below>
|
||||
<ui-editor-infos v-model="model" :disabled="disabled" />
|
||||
</template>
|
||||
</ui-editor>
|
||||
</ui-form>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import api from './api';
|
||||
|
||||
export default {
|
||||
props: ['id'],
|
||||
|
||||
data: () => ({
|
||||
meta: {},
|
||||
model: { },
|
||||
route: 'languages-edit',
|
||||
disabled: false
|
||||
}),
|
||||
|
||||
methods: {
|
||||
|
||||
async onLoad(form)
|
||||
{
|
||||
const response = await form.load(() => this.id ? api.getById(this.id) : api.getEmpty(this.$route.query['zero.flavor']));
|
||||
this.model = response;
|
||||
},
|
||||
|
||||
|
||||
async onSubmit(form)
|
||||
{
|
||||
const response = this.id ? await api.update(this.model) : await api.create(this.model);
|
||||
await form.handle(response);
|
||||
},
|
||||
|
||||
|
||||
onDelete(item, opts)
|
||||
{
|
||||
opts.hide();
|
||||
this.$refs.form.onDelete(api.delete.bind(this, this.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<div class="languages">
|
||||
<ui-header-bar title="@language.list" :count="count" :back-button="true">
|
||||
<ui-table-filter :attach="$refs.table" />
|
||||
<ui-add-button :route="createRoute" alias="languages" />
|
||||
</ui-header-bar>
|
||||
<div class="ui-blank-box">
|
||||
<ui-table ref="table" config="languages" @count="count = $event" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
data: () => ({
|
||||
count: 0,
|
||||
createRoute: 'languages-edit'
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,17 @@
|
||||
import { ZeroPlugin, ZeroPluginOptions } from '../../core';
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
|
||||
export default {
|
||||
name: "zero.languages",
|
||||
|
||||
install(app: ZeroPluginOptions)
|
||||
{
|
||||
//app.vue.component('ui-countrypicker', defineAsyncComponent(() => import('./ui-countrypicker.vue')));
|
||||
|
||||
app.route({ name: 'languages', path: '/settings/languages', component: () => import('./languages.vue') });
|
||||
app.route({ name: 'languages-edit', path: '/settings/languages/edit/:id?', component: () => import('./language.vue'), props: true });
|
||||
|
||||
app.schema('languages', () => import('./schemas/list'));
|
||||
app.schema('languages:edit', () => import('./schemas/editor'));
|
||||
}
|
||||
} as ZeroPlugin;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
|
||||
import Editor from 'zero/core/editor.ts';
|
||||
import Editor from '../../../editor/editor';
|
||||
|
||||
const editor = new Editor('language', '@language.fields.');
|
||||
const editor = new Editor('languages:edit', '@language.fields.');
|
||||
editor.blueprintAlias = 'language';
|
||||
editor.field('name', { label: '@ui.name' }).text(60).required();
|
||||
editor.field('code').text(10).required();
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
|
||||
import List from 'zero/core/list.ts';
|
||||
import LanguagesApi from 'zero/api/languages.js';
|
||||
import List from '../../../schemas/list/list';
|
||||
import api from '../api';
|
||||
|
||||
const list = new List('languages');
|
||||
const prefix = '@language.fields.';
|
||||
|
||||
list.templateLabel = x => prefix + x;
|
||||
list.link = zero.alias.settings.languages + '-edit';
|
||||
list.link = 'languages-edit';
|
||||
|
||||
list.onFetch(filter => LanguagesApi.getByQuery(filter));
|
||||
list.onFetch(filter => api.getByQuery(filter));
|
||||
|
||||
list.column('name').name();
|
||||
list.column('code').text();
|
||||
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<div class="ui-countrypicker" :class="{'is-disabled': disabled }">
|
||||
country picker
|
||||
<!--<ui-pick :config="pickerConfig" :value="value" @input="onChange" :disabled="disabled" />-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import api from './api';
|
||||
|
||||
export default {
|
||||
name: 'uiCountrypicker',
|
||||
|
||||
props: {
|
||||
modelValue: {
|
||||
type: [String, Array],
|
||||
default: null
|
||||
},
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
|
||||
data: () => ({
|
||||
previews: [],
|
||||
pickerConfig: {}
|
||||
}),
|
||||
|
||||
//created()
|
||||
//{
|
||||
// this.pickerConfig = _extend({
|
||||
// scope: 'country',
|
||||
// items: CountriesApi.getForPicker,
|
||||
// previews: CountriesApi.getPreviews,
|
||||
// limit: this.limit,
|
||||
// multiple: this.limit > 1,
|
||||
// preview: {
|
||||
|
||||
// }
|
||||
// }, this.options);
|
||||
//},
|
||||
|
||||
|
||||
//methods: {
|
||||
// onChange(value)
|
||||
// {
|
||||
// this.$emit('input', value);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user