Adds validation to collection form edit when no cover page is set.
This commit is contained in:
parent
c3f3986b19
commit
3dd69f9258
|
@ -747,7 +747,7 @@ class Collection extends Entity {
|
|||
}
|
||||
|
||||
if( $this->is_cover_page_enabled() && !is_numeric( $this->get_cover_page_id() ) ) {
|
||||
$this->add_error($this->get_id(), __('cover page is enabled, please inform the page', 'tainacan'));
|
||||
$this->add_error('cover_page_id', __('cover page is enabled, please inform the page', 'tainacan'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -463,7 +463,7 @@
|
|||
type="button"
|
||||
@click="cancelBack">{{ $i18n.get('cancel') }}</button>
|
||||
</div>
|
||||
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
<div
|
||||
style="margin-left: auto;"
|
||||
class="control">
|
||||
|
@ -487,7 +487,7 @@
|
|||
class="button is-success">{{ $i18n.get('finish') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
<br>
|
||||
</form>
|
||||
|
||||
<div v-if="!isLoading && ((isNewCollection && !$userCaps.hasCapability('tnc_rep_edit_collections')) || (!isNewCollection && collection && collection.current_user_can_edit != undefined && collection.current_user_can_edit == false))">
|
||||
|
@ -711,48 +711,49 @@ export default {
|
|||
this.fillExtraFormData(data);
|
||||
|
||||
this.updateCollection({collection_id: this.collectionId, collection: data })
|
||||
.then(updatedCollection => {
|
||||
|
||||
this.collection = updatedCollection;
|
||||
.then(updatedCollection => {
|
||||
|
||||
this.collection = updatedCollection;
|
||||
|
||||
// Fills hook forms with it's real values
|
||||
this.updateExtraFormData(this.collection);
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.collection.name;
|
||||
this.form.slug = this.collection.slug;
|
||||
this.form.description = this.collection.description;
|
||||
this.form.status = this.collection.status;
|
||||
this.form.cover_page_id = this.collection.cover_page_id;
|
||||
this.form.enable_cover_page = this.collection.enable_cover_page;
|
||||
this.form.enabled_view_modes = this.collection.enabled_view_modes.map((viewMode) => viewMode.viewMode);
|
||||
this.form.default_view_mode = this.collection.default_view_mode;
|
||||
this.form.allow_comments = this.collection.allow_comments;
|
||||
|
||||
this.isLoading = false;
|
||||
this.formErrorMessage = '';
|
||||
this.editFormErrors = {};
|
||||
// Fills hook forms with it's real values
|
||||
this.updateExtraFormData(this.collection);
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.collection.name;
|
||||
this.form.slug = this.collection.slug;
|
||||
this.form.description = this.collection.description;
|
||||
this.form.status = this.collection.status;
|
||||
this.form.cover_page_id = this.collection.cover_page_id;
|
||||
this.form.enable_cover_page = this.collection.enable_cover_page;
|
||||
this.form.enabled_view_modes = this.collection.enabled_view_modes.map((viewMode) => viewMode.viewMode);
|
||||
this.form.default_view_mode = this.collection.default_view_mode;
|
||||
this.form.allow_comments = this.collection.allow_comments;
|
||||
|
||||
this.isLoading = false;
|
||||
this.formErrorMessage = '';
|
||||
this.editFormErrors = {};
|
||||
|
||||
if (this.fromImporter)
|
||||
this.$router.go(-1);
|
||||
else {
|
||||
if (goTo == 'metadata')
|
||||
this.$router.push(this.$routerHelper.getCollectionMetadataPath(this.collectionId));
|
||||
else if (goTo == 'filters')
|
||||
this.$router.push(this.$routerHelper.getCollectionFiltersPath(this.collectionId));
|
||||
else
|
||||
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
|
||||
}
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.editFormErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
if (this.fromImporter)
|
||||
this.$router.go(-1);
|
||||
else {
|
||||
if (goTo == 'metadata')
|
||||
this.$router.push(this.$routerHelper.getCollectionMetadataPath(this.collectionId));
|
||||
else if (goTo == 'filters')
|
||||
this.$router.push(this.$routerHelper.getCollectionFiltersPath(this.collectionId));
|
||||
else
|
||||
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
|
||||
}
|
||||
})
|
||||
.catch((errors) => {
|
||||
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error))
|
||||
this.editFormErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
|
||||
this.isLoading = false;
|
||||
});
|
||||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
createNewCollection() {
|
||||
// Puts loading on Draft Collection creation
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
:label="$i18n.get('label_name')"
|
||||
:type="editFormErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['name'] != undefined ? editFormErrors['name'] : ''">
|
||||
<span class="required-metadatum-asterisk">*</span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('taxonomies', 'name')"
|
||||
:message="$i18n.getHelperMessage('taxonomies', 'name')"/>
|
||||
|
@ -178,6 +179,11 @@
|
|||
type="button"
|
||||
@click="cancelBack">{{ $i18n.get('cancel') }}</button>
|
||||
</div>
|
||||
<p
|
||||
style="margin: 0 12px;"
|
||||
class="help is-danger">
|
||||
{{ formErrorMessage }}
|
||||
</p>
|
||||
<p
|
||||
v-if="updatedAt != undefined"
|
||||
class="updated-at">
|
||||
|
@ -191,7 +197,6 @@
|
|||
class="button is-success">{{ $i18n.get('save') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
</form>
|
||||
|
||||
<div v-if="!isLoading && (($route.name == 'TaxonomyCreationForm' && !$userCaps.hasCapability('tnc_rep_edit_taxonomies')) || ($route.name == 'TaxonomyEditionForm' && taxonomy && taxonomy.current_user_can_edit != undefined && !taxonomy.current_user_can_edit))">
|
||||
|
|
Loading…
Reference in New Issue