Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources modals consistency #1846

Merged
merged 4 commits into from
Aug 23, 2018
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current (in progress)

- Prevent UnicodeError on unicode URL validation error [#1844](https://github.com/opendatateam/udata/pull/1844)
- Hide save button in "Add resource" modal until form is visible (and prevent error) [#1846](https://github.com/opendatateam/udata/pull/1846)

## 1.5.2 (2018-08-08)

Expand Down
25 changes: 18 additions & 7 deletions js/components/dataset/resource/add-modal.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<template>
<div>
<modal class="modal-primary add-resource-modal" v-ref:modal
:title="_('Add a resource')">
:title="_('Add a resource')" :large="editing">

<div class="modal-body">
<resource-form v-ref:form :dataset="dataset"></resource-form>
</div>

<footer class="modal-footer text-center">
<button type="button" class="btn btn-sm btn-primary btn-flat pull-left"
@click="$refs.modal.close">
{{ _('Cancel') }}
</button>
<button type="button"
class="btn btn-primary btn-flat pull-left"
v-show="$refs.form.resource.filetype"
class="btn btn-outline btn-flat"
v-show="editing"
@click="save">
{{ _('Save') }}
</button>
<button type="button" class="btn btn-outline btn-flat"
@click="$refs.modal.close">
{{ _('Cancel') }}
</button>
</footer>
</modal>
</div>
Expand All @@ -37,6 +37,17 @@ export default {
}
},
components: {Modal, ResourceForm},
data() {
return {ready: false};
},
computed: {
editing() {
return this.ready && this.$refs && this.$refs.form && this.$refs.form.hasData;
}
},
ready() {
this.ready = true; // Artificially force editing update because $refs is not reactive
},
methods: {
save() {
if (this.$refs.form.validate()) {
Expand Down
6 changes: 5 additions & 1 deletion js/components/dataset/resource/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<template>
<div>
<form-horizontal v-if="resource.url || hasChosenRemoteFile" class="resource-form file-resource-form"
<form-horizontal v-if="hasData" class="resource-form file-resource-form"
:fields="fields" :model="resource" v-ref:form>
</form-horizontal>
<div v-show="files.length" v-for="file in files" class="info-box bg-aqua">
Expand Down Expand Up @@ -192,6 +192,7 @@ export default {
}, {
id: 'description',
label: this._('Description'),
rows:3,
}, {
id: 'published',
label: this._('Publication date'),
Expand Down Expand Up @@ -226,6 +227,9 @@ export default {
};
},
computed: {
hasData() {
return Boolean(this.resource.url || this.hasChosenRemoteFile);
},
showUploadZone() {
if (this.files.length) return false;
if (this.hasChosenRemoteFile) return false;
Expand Down
2 changes: 1 addition & 1 deletion js/components/dataset/resource/modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<template>
<div>
<modal :title="resource.title" class="resource-modal"
<modal :title="resource.title" class="resource-modal" :large="edit"
:class="{ 'modal-danger': confirm, 'modal-primary': !confirm }"
v-ref:modal>
<div class="modal-body">
Expand Down
2 changes: 1 addition & 1 deletion js/components/form/markdown-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</style>

<template>
<textarea class="form-control" :rows="rows || 6"
<textarea class="form-control" :rows="field.rows || rows || 6"
:id="field.id"
:name="field.id"
:placeholder="placeholder"
Expand Down