Adds more default attributes to Field Edition.

This commit is contained in:
mateuswetah 2018-03-06 16:42:38 -03:00
parent cfc4b78752
commit cf8d457dbd
4 changed files with 41 additions and 38 deletions

View File

@ -24,38 +24,52 @@
<a @click.prevent="editField(field)" v-if="field.id != undefined"><b-icon icon="pencil" v-if="field.id != undefined"></b-icon></a> <a @click.prevent="editField(field)" v-if="field.id != undefined"><b-icon icon="pencil" v-if="field.id != undefined"></b-icon></a>
</div> </div>
<div v-if="openedFieldId == field.id"> <div v-if="openedFieldId == field.id">
<form id="fieldEditForm" class="box" v-on:submit.prevent="saveEdition(field)"> <form id="fieldEditForm" v-on:submit.prevent="saveEdition($event,field)">
<h1 class="is-size-4">{{ field.name }}</h1>
<h2 class="is-size-5">{{ $i18n.get('edit') }}</h2> <h2 class="is-size-5">{{ $i18n.get('edit') }}</h2>
<b-field :label="$i18n.get('label_name')"> <b-field :label="$i18n.get('label_name')" message="">
<b-input v-model="editForm.name"></b-input> <b-input v-model="editForm.name"></b-input>
</b-field> </b-field>
<b-field :label="$i18n.get('label_description')"> <b-field :label="$i18n.get('label_description')" message="">
<b-input type="textarea" v-model="editForm.description"></b-input> <b-input type="textarea" name="description" v-model="editForm.description"></b-input>
</b-field> </b-field>
<div class="field"> <div class="field">
<b-checkbox <b-switch
v-model="editForm.required" v-model="editForm.required"
true-value="yes" true-value="yes"
false-value="no"> false-value="no"
{{ $i18n.get('label_required') }} native-value="yes"
</b-checkbox> name="required">
{{ editForm.required }}
</b-switch>
</div> </div>
<div class="field"> <div class="field">
<b-checkbox <b-switch
v-model="editForm.multiple" v-model="isSwitchedCustom"
true-value="yes" true-value="yes"
false-value="no"> false-value="no"
{{ $i18n.get('label_allow_multiple') }} native-value="yes"
</b-checkbox> name="multiple">
{{ isSwitchedCustom }}
</b-switch>
</div> </div>
<b-field :label="$i18n.get('label_status')"> <b-field message="">
<b-switch
v-model="editForm.unique"
true-value="yes"
false-value="no"
native-value="yes"
name="collecion_key">
{{ $i18n.get('label_unique_value') }}
</b-switch>
</b-field>
<b-field :label="$i18n.get('label_status')" message="">
<b-select <b-select
id="tainacan-select-status" id="tainacan-select-status"
name="status" name="status"
@ -79,7 +93,6 @@
</form> </form>
</div> </div>
</div> </div>
</div>
<!-- <div class="not-sortable-item" slot="footer">{{ $i18n.get('instruction_dragndrop_fields_collection') }}</div> --> <!-- <div class="not-sortable-item" slot="footer">{{ $i18n.get('instruction_dragndrop_fields_collection') }}</div> -->
</draggable> </draggable>
@ -119,7 +132,8 @@ export default {
isLoadingFields: false, isLoadingFields: false,
isLoadingField: false, isLoadingField: false,
editForm: {}, editForm: {},
openedFieldId: '' openedFieldId: '',
isSwitchedCustom: 'yes'
} }
}, },
methods: { methods: {
@ -145,10 +159,12 @@ export default {
this.updateFieldsOrder(); this.updateFieldsOrder();
} }
}, },
saveEdition(field) { saveEdition($event, field) {
let formElement = document.getElementById('fieldEditForm'); let formElement = document.getElementById('fieldEditForm');
let formData = new FormData(formElement); let formData = new FormData(formElement);
this.openedFieldId = field.id; this.openedFieldId = field.id;
let formObj = {} let formObj = {}
for (var [key, value] of formData.entries()) { for (var [key, value] of formData.entries()) {
formObj[key] = value; formObj[key] = value;
@ -279,6 +295,9 @@ export default {
font-style: italic; font-style: italic;
color: gray; color: gray;
} }
form {
padding: 5px;
}
.loading-spinner { .loading-spinner {
animation: spinAround 500ms infinite linear; animation: spinAround 500ms infinite linear;
@ -331,23 +350,6 @@ export default {
} }
} }
#fieldEditForm {
position: absolute;
right: 0px;
padding: 20px;
height: 100%;
bottom: 0px;
width: 50%;
@media screen and (max-width: 769px) {
width: 50%;
position: relative;
box-shadow: none;
border: none;
padding: 10px;
}
}
</style> </style>

View File

@ -49,7 +49,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
data = {'meta': [{'metakey': metakey, 'metavalue': value, 'prevvalue': prevValue}]}; data = {'meta': [{'metakey': metakey, 'metavalue': value, 'prevvalue': prevValue}]};
else else
data = {'meta': [{'metakey': metakey, 'metavalue': value}]}; data = {'meta': [{'metakey': metakey, 'metavalue': value}]};
//data['delete'] = true;
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
wpApi.post('/wp/v2/users/me/?' + qs.stringify(data)) wpApi.post('/wp/v2/users/me/?' + qs.stringify(data))
.then( res => { .then( res => {

View File

@ -78,6 +78,8 @@ return [
'label_table_fields' => __('Fields on table', 'tainacan'), 'label_table_fields' => __('Fields on table', 'tainacan'),
'label_required' => __('Required', 'tainacan'), 'label_required' => __('Required', 'tainacan'),
'label_allow_multiple' => __('Allow multiple values', 'tainacan'), 'label_allow_multiple' => __('Allow multiple values', 'tainacan'),
'label_default_value' => __('Default value', 'tainacan'),
'label_unique_value' => __('Unique value', 'tainacan'),
// Instructions. More complex sentences to guide user and placeholders // Instructions. More complex sentences to guide user and placeholders
'instruction_dragndrop_fields_collection' => __('Drag and drop Fields here to add them to Collection.', 'tainacan'), 'instruction_dragndrop_fields_collection' => __('Drag and drop Fields here to add them to Collection.', 'tainacan'),

View File

@ -76,7 +76,6 @@ export const updateField = ( { commit }, { collectionId, fieldId, isRepositoryLe
else else
endpoint = '/fields/' + fieldId; endpoint = '/fields/' + fieldId;
console.log(options);
axios.put(endpoint, options) axios.put(endpoint, options)
.then( res => { .then( res => {
commit('setField', { collection_id: collectionId, name: name, field_type: fieldType, status: status }); commit('setField', { collection_id: collectionId, name: name, field_type: fieldType, status: status });