Merge pull request #6265 from jitendra-webkul/master
Issue #2308 fixed (Now attribute group's name can be changed)
This commit is contained in:
commit
d377d9ec1b
|
|
@ -685,6 +685,8 @@ return [
|
|||
'name' => 'اسم',
|
||||
'groups' => 'المجموعات',
|
||||
'add-group-title' => 'أضف المجموعة',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'موضع',
|
||||
'attribute-code' => 'الشفرة',
|
||||
'type' => 'النوع',
|
||||
|
|
|
|||
|
|
@ -676,6 +676,8 @@ return [
|
|||
'name' => 'Name',
|
||||
'groups' => 'Gruppen',
|
||||
'add-group-title' => 'Gruppe hinzufügen',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Position',
|
||||
'attribute-code' => 'Code',
|
||||
'type' => 'Typ',
|
||||
|
|
|
|||
|
|
@ -688,6 +688,8 @@ return [
|
|||
'name' => 'Name',
|
||||
'groups' => 'Groups',
|
||||
'add-group-title' => 'Add Group',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Position',
|
||||
'attribute-code' => 'Code',
|
||||
'type' => 'Type',
|
||||
|
|
|
|||
|
|
@ -690,6 +690,8 @@ return [
|
|||
'name' => 'Nombre',
|
||||
'groups' => 'Grupos',
|
||||
'add-group-title' => 'Agregar grupo',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Posición',
|
||||
'attribute-code' => 'Código',
|
||||
'type' => 'Tipo',
|
||||
|
|
|
|||
|
|
@ -673,6 +673,8 @@ return [
|
|||
'name' => 'نام',
|
||||
'groups' => 'گروه ها',
|
||||
'add-group-title' => 'افزودن گروه',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'موقعیت',
|
||||
'attribute-code' => 'کد',
|
||||
'type' => 'نوع',
|
||||
|
|
|
|||
|
|
@ -689,6 +689,8 @@ return [
|
|||
'name' => 'Nom',
|
||||
'groups' => 'Groupes',
|
||||
'add-group-title' => 'Ajouter un groupe',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Positionner',
|
||||
'attribute-code' => 'Code',
|
||||
'type' => 'Taper',
|
||||
|
|
|
|||
|
|
@ -688,6 +688,8 @@ return [
|
|||
'name' => 'नाम',
|
||||
'groups' => 'समूह',
|
||||
'add-group-title' => 'समूह जोड़ें',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'स्थान',
|
||||
'attribute-code' => 'कोड',
|
||||
'type' => 'प्रकार',
|
||||
|
|
|
|||
|
|
@ -673,6 +673,8 @@ return [
|
|||
'name' => 'Nome',
|
||||
'groups' => 'Gruppi',
|
||||
'add-group-title' => 'Aggiungi Gruppo',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Posizione',
|
||||
'attribute-code' => 'Codice',
|
||||
'type' => 'Tipo',
|
||||
|
|
|
|||
|
|
@ -672,6 +672,8 @@ return [
|
|||
'name' => 'Naam',
|
||||
'groups' => 'Groepen',
|
||||
'add-group-title' => 'Add Group',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Position',
|
||||
'attribute-code' => 'Code',
|
||||
'type' => 'Type',
|
||||
|
|
|
|||
|
|
@ -672,6 +672,8 @@ return [
|
|||
'name' => 'Nazwa',
|
||||
'groups' => 'Grupy',
|
||||
'add-group-title' => 'Dodaj grupę',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Pozycja',
|
||||
'attribute-code' => 'Kod',
|
||||
'type' => 'Rodzaj',
|
||||
|
|
|
|||
|
|
@ -671,6 +671,8 @@ return [
|
|||
'name' => 'Nome',
|
||||
'groups' => 'Grupos',
|
||||
'add-group-title' => 'Add Grupo',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Posição',
|
||||
'attribute-code' => 'Código',
|
||||
'type' => 'Tipo',
|
||||
|
|
|
|||
|
|
@ -678,6 +678,8 @@ return [
|
|||
'name' => 'Tanımı',
|
||||
'groups' => 'Gruplar',
|
||||
'add-group-title' => 'Grup Ekle',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => 'Konum',
|
||||
'attribute-code' => 'Nitelik Kodu',
|
||||
'type' => 'Tipi',
|
||||
|
|
|
|||
|
|
@ -673,6 +673,8 @@ return [
|
|||
'name' => '名称',
|
||||
'groups' => '客户群',
|
||||
'add-group-title' => '添加群',
|
||||
'edit-group-title' => 'Edit Group',
|
||||
'update-group-title' => 'Update Group',
|
||||
'position' => '位置',
|
||||
'attribute-code' => '代码',
|
||||
'type' => '类型',
|
||||
|
|
|
|||
|
|
@ -61,10 +61,6 @@
|
|||
<accordian title="{{ __('admin::app.catalog.families.groups') }}" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<button type="button" style="margin-bottom : 20px" class="btn btn-md btn-primary" @click="showModal('addGroup')">
|
||||
{{ __('admin::app.catalog.families.add-group-title') }}
|
||||
</button>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.family.create_form_accordian.groups.controls.before') !!}
|
||||
|
||||
<group-list></group-list>
|
||||
|
|
@ -81,29 +77,30 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<modal id="addGroup" :is-open="modalIds.addGroup">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.add-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<group-form></group-form>
|
||||
</div>
|
||||
</modal>
|
||||
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="group-form-template">
|
||||
<form method="POST" action="{{ route('admin.catalog.families.store') }}" data-vv-scope="add-group-form" @submit.prevent="addGroup('add-group-form')">
|
||||
<script type="text/x-template" id="group-list-template">
|
||||
<div>
|
||||
<button type="button" style="margin-bottom : 20px" class="btn btn-md btn-primary" @click="$root.showModal('addGroupForm')">
|
||||
{{ __('admin::app.catalog.families.add-group-title') }}
|
||||
</button>
|
||||
|
||||
<modal id="addGroupForm" :is-open="$root.modalIds.addGroupForm">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.add-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<form method="POST" data-vv-scope="add-group-form" @submit.prevent="addGroup('add-group-form')">
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<div class="control-group" :class="[errors.has('add-group-form.groupName') ? 'has-error' : '']">
|
||||
<label for="groupName" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="group.groupName" class="control" id="groupName" name="groupName" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('add-group-form.groupName')">@{{ errors.first('add-group-form.groupName') }}</span>
|
||||
<div class="control-group" :class="[errors.has('add-group-form.name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="group.name" class="control" id="name" name="name" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('add-group-form.name')">@{{ errors.first('add-group-form.name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('add-group-form.position') ? 'has-error' : '']">
|
||||
|
|
@ -120,24 +117,68 @@
|
|||
</div>
|
||||
|
||||
</form>
|
||||
</script>
|
||||
</div>
|
||||
</modal>
|
||||
|
||||
<script type="text/x-template" id="group-list-template">
|
||||
<div>
|
||||
<group-item v-for='(group, index) in groups' :group="group" :custom_attributes="custom_attributes" :key="index" :index="index" @onRemoveGroup="removeGroup($event)" @onAttributeAdd="addAttributes(index, $event)" @onAttributeRemove="removeAttribute(index, $event)"></group-item>
|
||||
<modal id="editGroupForm" :is-open="$root.modalIds.editGroupForm">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.edit-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<form method="POST" data-vv-scope="edit-group-form" @submit.prevent="updateGroup('edit-group-form')">
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
<div class="control-group" :class="[errors.has('edit-group-form.name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="editGroup.name" class="control" id="name" name="name" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('edit-group-form.name')">@{{ errors.first('edit-group-form.name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('edit-group-form.position') ? 'has-error' : '']">
|
||||
<label for="position" class="required">{{ __('admin::app.catalog.families.position') }}</label>
|
||||
<input type="text" v-validate="'required|numeric'" v-model="editGroup.position" class="control" id="position" name="position" data-vv-as=""{{ __('admin::app.catalog.families.position') }}""/>
|
||||
<span class="control-error" v-if="errors.has('edit-group-form.position')">@{{ errors.first('edit-group-form.position') }}</span>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.catalog.families.update-group-title') }}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</modal>
|
||||
|
||||
<group-item
|
||||
v-for='(group, index) in groups'
|
||||
:group="group"
|
||||
:custom_attributes="custom_attributes"
|
||||
:key="index"
|
||||
:index="index"
|
||||
@onRemoveGroup="removeGroup($event)"
|
||||
@onEditGroup="openEditGroupModal($event)"
|
||||
@onAttributeAdd="addAttributes(index, $event)"
|
||||
@onAttributeRemove="removeAttribute(index, $event)"
|
||||
></group-item>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-template" id="group-item-template">
|
||||
<accordian :title="group.groupName" :active="true">
|
||||
<accordian :title="group.name" :active="true">
|
||||
<div slot="header">
|
||||
<i class="icon expand-icon left"></i>
|
||||
<h1>@{{ group.name ? group.name : group.groupName }}</h1>
|
||||
|
||||
<h1>@{{ group.name }}</h1>
|
||||
|
||||
<i class="icon trash-icon" @click="removeGroup()" v-if="group.is_user_defined"></i>
|
||||
|
||||
<span class="icon pencil-lg-icon" @click="editGroup()"></span>
|
||||
</div>
|
||||
|
||||
<div slot="body">
|
||||
<input type="hidden" :name="[groupInputName + '[name]']" :value="group.name ? group.name : group.groupName"/>
|
||||
<input type="hidden" :name="[groupInputName + '[name]']" :value="group.name"/>
|
||||
<input type="hidden" :name="[groupInputName + '[position]']" :value="group.position"/>
|
||||
<input type="hidden" :name="[groupInputName + '[is_user_defined]']" :value="group.is_user_defined"/>
|
||||
|
||||
|
|
@ -201,71 +242,28 @@
|
|||
var groups = @json($attributeFamily ? $attributeFamily->attribute_groups : []);
|
||||
var custom_attributes = @json($custom_attributes);
|
||||
|
||||
Vue.component('group-form', {
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
group: {
|
||||
'groupName': '',
|
||||
'position': '',
|
||||
'is_user_defined': 1,
|
||||
'custom_attributes': []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
template: '#group-form-template',
|
||||
|
||||
methods: {
|
||||
addGroup: function (formScope) {
|
||||
var this_this = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return this_this.group.groupName.trim() === (group.name ? group.name.trim() : group.groupName.trim())
|
||||
})
|
||||
|
||||
if (filteredGroups.length) {
|
||||
const field = this.$validator.fields.find({ name: 'groupName', scope: 'add-group-form' });
|
||||
|
||||
if (field) {
|
||||
this.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'groupName',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'add-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
groups.push(this_this.group);
|
||||
|
||||
groups = this_this.sortGroups();
|
||||
|
||||
this.group = {'groupName': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
this_this.$parent.closeModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
sortGroups: function () {
|
||||
return groups.sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('group-list', {
|
||||
|
||||
template: '#group-list-template',
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
group: {
|
||||
'name': '',
|
||||
'position': '',
|
||||
'is_user_defined': 1,
|
||||
'custom_attributes': []
|
||||
},
|
||||
|
||||
editGroup: {
|
||||
'name': '',
|
||||
'position': '',
|
||||
'is_user_defined': 1,
|
||||
'custom_attributes': []
|
||||
},
|
||||
|
||||
groups: groups,
|
||||
|
||||
custom_attributes: custom_attributes
|
||||
}
|
||||
},
|
||||
|
|
@ -286,6 +284,88 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
addGroup: function (formScope) {
|
||||
var self = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return self.group.name.trim() === group.name.trim()
|
||||
})
|
||||
|
||||
if (filteredGroups.length) {
|
||||
const field = self.$validator.fields.find({ name: 'name', scope: 'add-group-form' });
|
||||
|
||||
if (field) {
|
||||
self.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'name',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'add-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
groups.push(self.group);
|
||||
|
||||
groups = self.sortGroups();
|
||||
|
||||
this.group = {'name': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
self.$set(self.$root.modalIds, 'addGroupForm', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateGroup: function(formScope) {
|
||||
var self = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return self.editGroup.name.trim() === group.name.trim()
|
||||
})
|
||||
|
||||
if (filteredGroups.length > 1) {
|
||||
const field = self.$validator.fields.find({ name: 'name', scope: 'edit-group-form' });
|
||||
|
||||
if (field) {
|
||||
self.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'name',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'edit-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let index = groups.indexOf(self.editGroup)
|
||||
|
||||
groups[index] = self.editGroup;
|
||||
|
||||
groups = self.sortGroups();
|
||||
|
||||
this.editGroup = {'name': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
self.$set(self.$root.modalIds, 'editGroupForm', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
sortGroups: function () {
|
||||
return groups.sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
});
|
||||
},
|
||||
|
||||
openEditGroupModal: function (group) {
|
||||
this.editGroup = group;
|
||||
|
||||
this.$root.showModal('editGroupForm')
|
||||
},
|
||||
|
||||
removeGroup: function (group) {
|
||||
group.custom_attributes.forEach(function(attribute) {
|
||||
this.custom_attributes.push(attribute);
|
||||
|
|
@ -342,6 +422,10 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
editGroup: function() {
|
||||
this.$emit('onEditGroup', this.group)
|
||||
},
|
||||
|
||||
removeGroup: function () {
|
||||
this.$emit('onRemoveGroup', this.group)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,10 +64,6 @@
|
|||
|
||||
{!! view_render_event('bagisto.admin.catalog.family.edit_form_accordian.groups.controls.before', ['attributeFamily' => $attributeFamily]) !!}
|
||||
|
||||
<button type="button" style="margin-bottom : 20px" class="btn btn-md btn-primary" @click="showModal('addGroup')">
|
||||
{{ __('admin::app.catalog.families.add-group-title') }}
|
||||
</button>
|
||||
|
||||
<group-list></group-list>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.family.edit_form_accordian.groups.controls.before', ['attributeFamily' => $attributeFamily]) !!}
|
||||
|
|
@ -81,29 +77,28 @@
|
|||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<modal id="addGroup" :is-open="modalIds.addGroup">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.add-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<group-form></group-form>
|
||||
</div>
|
||||
</modal>
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="group-form-template">
|
||||
<form method="POST" action="{{ route('admin.catalog.families.store') }}" data-vv-scope="add-group-form" @submit.prevent="addGroup('add-group-form')">
|
||||
<script type="text/x-template" id="group-list-template">
|
||||
<div style="margin-top: 20px">
|
||||
<button type="button" style="margin-bottom : 20px" class="btn btn-md btn-primary" @click="showModal('addGroupForm')">
|
||||
{{ __('admin::app.catalog.families.add-group-title') }}
|
||||
</button>
|
||||
|
||||
<modal id="addGroupForm" :is-open="$root.modalIds.addGroupForm">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.add-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<form method="POST" data-vv-scope="add-group-form" @submit.prevent="addGroup('add-group-form')">
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<div class="control-group" :class="[errors.has('add-group-form.groupName') ? 'has-error' : '']">
|
||||
<label for="groupName" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="group.groupName" class="control" id="groupName" name="groupName" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('add-group-form.groupName')">@{{ errors.first('add-group-form.groupName') }}</span>
|
||||
<div class="control-group" :class="[errors.has('add-group-form.name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="group.name" class="control" id="name" name="name" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('add-group-form.name')">@{{ errors.first('add-group-form.name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('add-group-form.position') ? 'has-error' : '']">
|
||||
|
|
@ -120,24 +115,68 @@
|
|||
</div>
|
||||
|
||||
</form>
|
||||
</script>
|
||||
</div>
|
||||
</modal>
|
||||
|
||||
<script type="text/x-template" id="group-list-template">
|
||||
<div style="margin-top: 20px">
|
||||
<group-item v-for='(group, index) in groups' :group="group" :custom_attributes="custom_attributes" :key="index" :index="index" @onRemoveGroup="removeGroup($event)" @onAttributeAdd="addAttributes(index, $event)" @onAttributeRemove="removeAttribute(index, $event)"></group-item>
|
||||
<modal id="editGroupForm" :is-open="$root.modalIds.editGroupForm">
|
||||
<h3 slot="header">{{ __('admin::app.catalog.families.edit-group-title') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<form method="POST" data-vv-scope="edit-group-form" @submit.prevent="updateGroup('edit-group-form')">
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
<div class="control-group" :class="[errors.has('edit-group-form.name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.catalog.families.name') }}</label>
|
||||
<input type="text" v-validate="'required'" v-model="editGroup.name" class="control" id="name" name="name" data-vv-as=""{{ __('admin::app.catalog.families.name') }}""/>
|
||||
<span class="control-error" v-if="errors.has('edit-group-form.name')">@{{ errors.first('edit-group-form.name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('edit-group-form.position') ? 'has-error' : '']">
|
||||
<label for="position" class="required">{{ __('admin::app.catalog.families.position') }}</label>
|
||||
<input type="text" v-validate="'required|numeric'" v-model="editGroup.position" class="control" id="position" name="position" data-vv-as=""{{ __('admin::app.catalog.families.position') }}""/>
|
||||
<span class="control-error" v-if="errors.has('edit-group-form.position')">@{{ errors.first('edit-group-form.position') }}</span>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.catalog.families.update-group-title') }}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</modal>
|
||||
|
||||
<group-item
|
||||
v-for='(group, index) in groups'
|
||||
:group="group"
|
||||
:custom_attributes="custom_attributes"
|
||||
:key="index"
|
||||
:index="index"
|
||||
@onRemoveGroup="removeGroup($event)"
|
||||
@onEditGroup="openEditGroupModal($event)"
|
||||
@onAttributeAdd="addAttributes(index, $event)"
|
||||
@onAttributeRemove="removeAttribute(index, $event)"
|
||||
></group-item>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-template" id="group-item-template">
|
||||
<accordian :title="group.groupName" :active="true">
|
||||
<accordian :title="group.name" :active="true">
|
||||
<div slot="header">
|
||||
<i class="icon expand-icon left"></i>
|
||||
<h1>@{{ group.name ? group.name : group.groupName }}</h1>
|
||||
|
||||
<h1>@{{ group.name }}</h1>
|
||||
|
||||
<i class="icon trash-icon" @click="removeGroup()" v-if="group.is_user_defined"></i>
|
||||
|
||||
<span class="icon pencil-lg-icon" @click="editGroup()"></span>
|
||||
</div>
|
||||
|
||||
<div slot="body">
|
||||
<input type="hidden" :name="[groupInputName + '[name]']" :value="group.name ? group.name : group.groupName"/>
|
||||
<input type="hidden" :name="[groupInputName + '[name]']" :value="group.name"/>
|
||||
<input type="hidden":name="[groupInputName + '[position]']" :value="group.position"/>
|
||||
|
||||
<div class="table" v-if="group.custom_attributes.length" style="margin-bottom: 20px;">
|
||||
|
|
@ -200,70 +239,27 @@
|
|||
var groups = @json($attributeFamily->attribute_groups);
|
||||
var custom_attributes = @json($custom_attributes);
|
||||
|
||||
Vue.component('group-form', {
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
group: {
|
||||
'groupName': '',
|
||||
'position': '',
|
||||
'custom_attributes': []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
template: '#group-form-template',
|
||||
|
||||
methods: {
|
||||
addGroup: function (formScope) {
|
||||
var this_this = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return this_this.group.groupName.trim() === (group.name ? group.name.trim() : group.groupName.trim())
|
||||
})
|
||||
|
||||
if (filteredGroups.length) {
|
||||
const field = this.$validator.fields.find({ name: 'groupName', scope: 'add-group-form' });
|
||||
|
||||
if (field) {
|
||||
this.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'groupName',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'add-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
groups.push(this_this.group);
|
||||
|
||||
groups = this_this.sortGroups();
|
||||
|
||||
this.group = {'groupName': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
this_this.$parent.closeModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
sortGroups: function () {
|
||||
return groups.sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('group-list', {
|
||||
|
||||
template: '#group-list-template',
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
group: {
|
||||
'name': '',
|
||||
'position': '',
|
||||
'custom_attributes': []
|
||||
},
|
||||
|
||||
editGroup: {
|
||||
'name': '',
|
||||
'position': '',
|
||||
'is_user_defined': 1,
|
||||
'custom_attributes': []
|
||||
},
|
||||
|
||||
groups: groups,
|
||||
|
||||
custom_attributes: custom_attributes
|
||||
}
|
||||
},
|
||||
|
|
@ -286,6 +282,88 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
addGroup: function (formScope) {
|
||||
var this_this = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return this_this.group.name.trim() === group.name.trim()
|
||||
})
|
||||
|
||||
if (filteredGroups.length) {
|
||||
const field = this.$validator.fields.find({ name: 'name', scope: 'add-group-form' });
|
||||
|
||||
if (field) {
|
||||
this.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'name',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'add-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
groups.push(this_this.group);
|
||||
|
||||
groups = this_this.sortGroups();
|
||||
|
||||
this.group = {'name': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
self.$set(self.$root.modalIds, 'addGroupForm', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateGroup: function(formScope) {
|
||||
var self = this;
|
||||
|
||||
this.$validator.validateAll(formScope).then(function (result) {
|
||||
if (result) {
|
||||
|
||||
var filteredGroups = groups.filter(function(group) {
|
||||
return self.editGroup.name.trim() === group.name.trim()
|
||||
})
|
||||
|
||||
if (filteredGroups.length > 1) {
|
||||
const field = self.$validator.fields.find({ name: 'name', scope: 'edit-group-form' });
|
||||
|
||||
if (field) {
|
||||
self.$validator.errors.add({
|
||||
id: field.id,
|
||||
field: 'name',
|
||||
msg: "{{ __('admin::app.catalog.families.group-exist-error') }}",
|
||||
scope: 'edit-group-form',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let index = groups.indexOf(self.editGroup)
|
||||
|
||||
groups[index] = self.editGroup;
|
||||
|
||||
groups = self.sortGroups();
|
||||
|
||||
this.editGroup = {'name': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
|
||||
|
||||
self.$set(self.$root.modalIds, 'editGroupForm', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
sortGroups: function () {
|
||||
return groups.sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
});
|
||||
},
|
||||
|
||||
openEditGroupModal: function (group) {
|
||||
this.editGroup = group;
|
||||
|
||||
this.$root.showModal('editGroupForm')
|
||||
},
|
||||
|
||||
removeGroup: function (group) {
|
||||
group.custom_attributes.forEach(function(attribute) {
|
||||
this.custom_attributes.push(attribute);
|
||||
|
|
@ -347,6 +425,10 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
editGroup: function() {
|
||||
this.$emit('onEditGroup', this.group)
|
||||
},
|
||||
|
||||
removeGroup: function () {
|
||||
this.$emit('onRemoveGroup', this.group)
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/ui.js": "/js/ui.js?id=a13fbc5b58c0a7b9c6ee",
|
||||
"/js/ui.js": "/js/ui.js?id=a2b05e91c1d8facc7948",
|
||||
"/css/ui.css": "/css/ui.css?id=243bb2330a1ea80658f5"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
inject: ['$validator'],
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
id: String,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
export default {
|
||||
props: ['id', 'isOpen'],
|
||||
|
||||
inject: ['$validator'],
|
||||
|
||||
created () {
|
||||
this.closeModal();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue