Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions generators/testdata/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ const (
PackageVTUpdated = "vt-updated"
PackageDBTest = "test"

PrefixAll = "all"
PrefixEntity = "entities"
PrefixAll = "all"
PrefixEntity = "entities"
PrefixComposition = "composition"
)

var (
PathActual = filepath.Join(DirParent, DirTestdata, "actual")
PathExpected = filepath.Join(DirParent, DirTestdata, "expected")

PathActualMFD = filepath.Join(PathActual, FilenameMFD)
PathExpectedMFD = filepath.Join(PathExpected, FilenameMFD)
PathActualDB = filepath.Join(PathActual, PackageDB)
PathExpectedDB = filepath.Join(PathExpected, PackageDB)
PathActualVT = filepath.Join(PathActual, PackageVT)
PathUpdatedVT = filepath.Join(PathExpected, PackageVTUpdated)
PathExpectedVT = filepath.Join(PathExpected, PackageVT)
PathActualVTTemplateAll = filepath.Join(PathActual, PackageVTTemplate, PrefixAll)
PathExpectedVTTemplateAll = filepath.Join(PathExpected, PackageVTTemplate, PrefixAll)
PathActualVTTemplateEntity = filepath.Join(PathActual, PackageVTTemplate, PrefixEntity)
PathExpectedVTTemplateEntity = filepath.Join(PathExpected, PackageVTTemplate, PrefixEntity)
PathActualDBTest = filepath.Join(PathActual, PackageDB, PackageDBTest)
PathExpectedDBTest = filepath.Join(PathExpected, PackageDB, PackageDBTest)
PathActualMFD = filepath.Join(PathActual, FilenameMFD)
PathExpectedMFD = filepath.Join(PathExpected, FilenameMFD)
PathActualDB = filepath.Join(PathActual, PackageDB)
PathExpectedDB = filepath.Join(PathExpected, PackageDB)
PathActualVT = filepath.Join(PathActual, PackageVT)
PathUpdatedVT = filepath.Join(PathExpected, PackageVTUpdated)
PathExpectedVT = filepath.Join(PathExpected, PackageVT)
PathActualVTTemplateAll = filepath.Join(PathActual, PackageVTTemplate, PrefixAll)
PathExpectedVTTemplateAll = filepath.Join(PathExpected, PackageVTTemplate, PrefixAll)
PathActualVTTemplateEntity = filepath.Join(PathActual, PackageVTTemplate, PrefixEntity)
PathExpectedVTTemplateEntity = filepath.Join(PathExpected, PackageVTTemplate, PrefixEntity)
PathActualVTTemplateComposition = filepath.Join(PathActual, PackageVTTemplate, PrefixComposition)
PathExpectedVTTemplateComposition = filepath.Join(PathExpected, PackageVTTemplate, PrefixComposition)
PathActualDBTest = filepath.Join(PathActual, PackageDB, PackageDBTest)
PathExpectedDBTest = filepath.Join(PathExpected, PackageDB, PackageDBTest)
)
23 changes: 23 additions & 0 deletions generators/testdata/expected/media.vt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<VTNamespace xmlns:xsi="" xmlns:xsd="">
<Name>media</Name>
<VTEntities>
<Entity Name="Page" Mode="Full">
<TerminalPath>pages</TerminalPath>
<Attributes>
<Attribute Name="ID" AttrName="ID" SearchName="ID" Summary="true" Search="true" Max="0" Min="0" Required="false" Validate=""></Attribute>
<Attribute Name="Title" AttrName="Title" SearchName="TitleILike" Summary="true" Search="true" Max="255" Min="0" Required="true" Validate=""></Attribute>
<Attribute Name="Alias" AttrName="Alias" SearchName="Alias" Summary="true" Search="false" Max="255" Min="0" Required="true" Validate=""></Attribute>
<Attribute Name="ImageID" AttrName="ImageID" SearchName="ImageID" Summary="true" Search="false" Max="0" Min="0" Required="true" Validate=""></Attribute>
<Attribute Name="StatusID" AttrName="StatusID" SearchName="StatusID" Summary="true" Search="true" Max="0" Min="0" Required="true" Validate="status"></Attribute>
<Attribute Name="IDs" SearchName="IDs" Summary="false" Search="true" Max="0" Min="0" Required="false" Validate=""></Attribute>
</Attributes>
<Template>
<Attribute Name="Title" VTAttrName="Title" List="true" Form="HTML_INPUT" Search="HTML_INPUT"></Attribute>
<Attribute Name="Alias" VTAttrName="Alias" List="false" Form="HTML_INPUT" Search="HTML_NONE"></Attribute>
<Attribute Name="Image" VTAttrName="ImageID" List="false" Form="HTML_FILE" Search="HTML_NONE"></Attribute>
<Attribute Name="StatusID" VTAttrName="StatusID" List="true" Form="HTML_INPUT" Search="HTML_INPUT"></Attribute>
<Attribute Name="IDs" VTAttrName="IDs" List="false" Form="HTML_NONE" Search="HTML_SELECT"></Attribute>
</Template>
</Entity>
</VTEntities>
</VTNamespace>
18 changes: 18 additions & 0 deletions generators/testdata/expected/media.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Package xmlns:xsi="" xmlns:xsd="">
<Name>media</Name>
<Entities>
<Entity Name="Page" Namespace="media" Table="pages">
<Attributes>
<Attribute Name="ID" DBName="pageId" DBType="int4" GoType="int" PK="true" Nullable="Yes" Addable="true" Updatable="false" Min="0" Max="0" HasDefault="true"></Attribute>
<Attribute Name="Title" DBName="title" DBType="varchar" GoType="string" PK="false" Nullable="No" Addable="true" Updatable="true" Min="0" Max="255"></Attribute>
<Attribute Name="Alias" DBName="alias" DBType="varchar" GoType="string" PK="false" Nullable="No" Addable="true" Updatable="true" Min="0" Max="255"></Attribute>
<Attribute Name="ImageID" DBName="imageId" DBType="int4" GoType="int" PK="false" FK="VfsFile" Nullable="No" Addable="true" Updatable="true" Min="0" Max="0"></Attribute>
<Attribute Name="StatusID" DBName="statusId" DBType="int4" GoType="int" PK="false" Nullable="No" Addable="true" Updatable="true" Min="0" Max="0"></Attribute>
</Attributes>
<Searches>
<Search Name="IDs" AttrName="ID" SearchType="SEARCHTYPE_ARRAY"></Search>
<Search Name="TitleILike" AttrName="Title" SearchType="SEARCHTYPE_ILIKE"></Search>
</Searches>
</Entity>
</Entities>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<template>
<vt-entity-view>
<v-layout
align-start
justify-center
>
<v-flex
xs12
md8
mb-2
>
<v-layout
mb-2
wrap
>
<v-flex>
<h2 class="ellipsed">
{{ model.title || "..." }}
</h2>
</v-flex>
<v-spacer />
<v-flex shrink>
<v-btn
text
color="primary"
:disabled="isLoading"
@click.stop="navigateBack"
>
<v-icon
:left="!$vuetify.breakpoint.xsOnly"
>
arrow_back
</v-icon>
<template v-if="!$vuetify.breakpoint.xsOnly">
{{ t("common.form.cancelButtonLabel") }}
</template>
</v-btn>
<v-hover
v-if="$route.params.id"
v-slot="{ hover }"
>
<v-btn
:color="hover ? 'error' : ''"
icon
@click.stop="onDelete('title')"
>
<v-icon>delete</v-icon>
</v-btn>
</v-hover>
</v-flex>
</v-layout>
<v-tabs
v-model="tab"
mobile-break-point="0"
>
<v-tab
:class="{
'error--text': tabsHasError.includes(0)
}"
>
Основные
</v-tab>
</v-tabs>
<v-card v-if="model">
<v-form
ref="form"
@submit.prevent="onSaveAndBack"
>
<v-card-text>
<v-tabs-items v-model="tab">
<v-tab-item eager>
<!-- generated part -->
<vt-form-field
v-model="model.title"
component="v-text-field"
:label="t('category.form.titleLabel')"
:error-messages="getErrorMessage(errors.title)"
:disabled="isLoading"
placeholder=""
required
/><vt-form-field
v-model="model.orderNumber"
component="v-text-field"
:label="t('category.form.orderNumberLabel')"
:error-messages="getErrorMessage(errors.orderNumber)"
:disabled="isLoading"
placeholder=""
required
/><vt-form-field
v-model="model.statusId"
component="vt-status-select"
:label="t('category.form.statusIdLabel')"
:error-messages="getErrorMessage(errors.statusId)"
:disabled="isLoading"
placeholder=""
required
compact
:row="$vuetify.breakpoint.smAndUp"
/><!-- end generated part -->
</v-tab-item>
</v-tabs-items>
</v-card-text>
<v-card-actions>
<v-layout wrap>
<v-flex
v-if="$vuetify.breakpoint.smAndUp"
xs3
/>
<v-flex>
<v-layout wrap>
<v-btn
type="submit"
color="success"
:disabled="!isChanged || isLoading"
:loading="isLoading"
:block="$vuetify.breakpoint.xsOnly"
:class="!$vuetify.breakpoint.xsOnly && 'mx-2'"
>
<v-icon left>
done
</v-icon>
{{ t("common.form.saveAndCloseButtonLabel") }}
</v-btn>

<v-btn
v-if="$route.params.id"
:disabled="!isChanged || isLoading"
:loading="isLoading"
:block="$vuetify.breakpoint.xsOnly"
:class="[
$vuetify.breakpoint.xsOnly && 'ml-0 mt-2',
$vuetify.breakpoint.smAndUp && 'ml-2'
]"
outlined
color="accent"
@click.stop="onSave"
>
{{ t("common.form.saveButtonLabel") }}
</v-btn>
<v-spacer />
</v-layout>
</v-flex>
</v-layout>
</v-card-actions>
</v-form>
</v-card>
</v-flex>
</v-layout>
</vt-entity-view>
</template>

<script lang="ts">
import { useEntityForm } from '@/composables/useEntityForm';
import { useI18n } from '@/composables/useI18n'
import { Category as Model } from '@/services/api/factory';
import { defineComponent } from 'vue';

export default defineComponent({
// eslint-disable-next-line vue/match-component-file-name
name: 'CategoryForm',

setup () {
const { t } = useI18n();

const {
tab,
form,
model,
errors,
isLoading,
isChanged,
i18nFieldError,
tabsHasError,

onSave,
onDelete,
navigateBack,
onSaveAndBack
} = useEntityForm<Model>({ Model} );

const getErrorMessage = (errorKey: string | null): string => {
const errorMessage = i18nFieldError(errorKey);
return errorMessage ? t(errorMessage) : '';
};

return {
t,
tab,
form,
model,
errors,
isLoading,
isChanged,
i18nFieldError,
tabsHasError,
getErrorMessage,

onSave,
onDelete,
navigateBack,
onSaveAndBack
};
}
});
</script>

<style scoped></style>
Loading
Loading