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

Show resource type in modal (front) #1714

Merged
merged 3 commits into from Jun 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -26,6 +26,7 @@
- Fix 404/missing css on front pages [#1709](https://github.com/opendatateam/udata/pull/1709)
- Fix markdown max image width (front) [#1707](https://github.com/opendatateam/udata/pull/1707)
- Adds ETag to internal avatar for efficient caching control [#1712](https://github.com/opendatateam/udata/pull/1712)
- Show resource type in modal (front) [#1714](https://github.com/opendatateam/udata/pull/1714)

## 1.3.12 (2018-05-31)

Expand Down
2 changes: 1 addition & 1 deletion js/front/dataset/index.js
Expand Up @@ -24,7 +24,6 @@ import ShareButton from 'components/buttons/share.vue';
import IntegrateButton from 'components/buttons/integrate.vue';
import IssuesButton from 'components/buttons/issues.vue';
import DiscussionThreads from 'components/discussions/threads.vue';
import resource_types from 'models/resource_types';


function parseUrl(url) {
Expand Down Expand Up @@ -102,6 +101,7 @@ new Vue({
modified: resourceJsonLd.dateModified,
published: resourceJsonLd.datePublished,
description: resourceJsonLd.description,
type: resourceJsonLd.type,
};
if (resourceJsonLd.interactionStatistic) {
resource.metrics = {
Expand Down
27 changes: 24 additions & 3 deletions js/front/dataset/resource-modal.vue
Expand Up @@ -9,6 +9,8 @@
<dd><a :href="resource.url" @click="onClick">{{resource.url}}</a></dd>
<dt>{{ _('Latest URL') }}</dt>
<dd><a :href="resource.latest" @click="onClick">{{resource.latest}}</a></dd>
<dt v-if="resourceType">{{ _('Type') }}</dt>
<dd v-if="resourceType">{{ resourceType }}</dd>
<dt v-if="resource.format">{{ _('Format') }}</dt>
<dd v-if="resource.format">{{resource.format}}</dd>
<dt v-if="resource.mime">{{ _('MimeType') }}</dt>
Expand Down Expand Up @@ -43,10 +45,11 @@
</template>

<script>
import Modal from 'components/modal.vue';
import Resource from 'models/resource';
import Availability from './resource/availability.vue';
import Modal from 'components/modal.vue';
import pubsub from 'pubsub';
import Resource from 'models/resource';
import resource_types from 'models/resource_types';

export default {
props: {
Expand All @@ -60,11 +63,24 @@ export default {
}
},
components: {Modal, Availability},
data() {
return {
resourceType: undefined,
}
},
created() {
const url = `datasets/${this.datasetId}/resources/${this.resource.id}/`;
this.$api.get(url).then(resource => {
Object.assign(this.resource, resource);
});
// ensure this will be filled both on open from dataset page and direct open (deeplink)
if (resource_types.has_data) {
this.fillResourceType();
} else {
resource_types.$on('updated', (res) => {
this.fillResourceType();
});
}
},
methods: {
onClick() {
Expand All @@ -76,7 +92,12 @@ export default {
}
pubsub.publish(eventName);
this.$refs.modal.close();
}
},
fillResourceType() {
if (this.resource.type) {
this.resourceType = resource_types.by_id(this.resource.type).label;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a computed property ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not working :-(

}
},
}
};
</script>
Expand Down