diff --git a/CHANGELOG.md b/CHANGELOG.md index e357f0b9d..36f1c955b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## UNRELEASED +### Changed + +- ([#91](https://github.com/demos-europe/demosplan-ui/pull/91)) Pass routes as props ([@ahmad-demos](https://github.com/ahmad-demos)) + + ### Fixed - ([#100](https://github.com/demos-europe/demosplan-ui/pull/100)) Set correct value for `aria-live` in DpNotifyContainer when document becomes visible ([@spiess-demos](https://github.com/spiess-demos)) diff --git a/src/components/core/DpAutocomplete.vue b/src/components/core/DpAutocomplete.vue index 7f7c6cf5c..eea1f5b22 100644 --- a/src/components/core/DpAutocomplete.vue +++ b/src/components/core/DpAutocomplete.vue @@ -33,12 +33,6 @@ export default { mixins: [prefixClassMixin], props: { - additionalRouteParams: { - type: Object, - required: false, - default: () => ({}) - }, - height: { type: String, required: false, @@ -63,14 +57,8 @@ export default { default: () => Translator.trans('search') }, - queryParam: { - type: String, - required: false, - default: 'query' - }, - - route: { - type: String, + routeGenerator: { + type: Function, required: true }, @@ -110,7 +98,8 @@ export default { async fetchOptions (searchString) { this.isLoading = true try { - const response = await dpApi.get(Routing.generate(this.route, { ...this.additionalRouteParams, [this.queryParam]: searchString })) + const route = this.routeGenerator(searchString) + const response = await dpApi.get(route) // Only emit results that match the current search -> prevents race conditions if (this.currentQuerry === searchString) this.$emit('search-changed', response) this.isLoading = false diff --git a/src/components/core/DpEditor/DpBoilerPlateModal.vue b/src/components/core/DpEditor/DpBoilerPlateModal.vue index 7a80df813..7d826ca8d 100644 --- a/src/components/core/DpEditor/DpBoilerPlateModal.vue +++ b/src/components/core/DpEditor/DpBoilerPlateModal.vue @@ -14,8 +14,9 @@ @boilerplate-text-added="addBoilerplateText" />
+ v-if="boilerplateEditViewRoute" + class="weight--bold font-size-small" + :href="boilerplateEditViewRoute"> {{ Translator.trans('boilerplates.edit') }} ({{ Translator.trans('view.leave.hint') }}) @@ -18,6 +19,7 @@ @@ -26,7 +28,8 @@ ref="recommendationModal" @insert-recommendation="text => appendText(text)" :procedure-id="procedureId" - :segment-id="segmentId" /> + :segment-id="segmentId" + :similar-recommendations-route="routes.similarRecommendationsRoute" />
({}), + validator: (prop) => { + return Object.keys(prop).every(key => [ + 'boilerplateEditViewRoute', + 'getFileByHash', + 'similarRecommendationsRoute' + ].includes(key)) + } + }, + segmentId: { type: String, required: false, @@ -907,7 +933,7 @@ export default { const imageHash = placeholder.substr(7, 36) const imageWidth = placeholder.match(/width=(\d*?)&/)[1] const imageHeight = placeholder.match(/height=(\d*?)$/)[1] - return `${altText}` + return `${altText}` }) } catch (e) { return text diff --git a/src/components/core/DpEditor/DpRecommendationModal.vue b/src/components/core/DpEditor/DpRecommendationModal.vue index 840628b76..9f0b7be45 100644 --- a/src/components/core/DpEditor/DpRecommendationModal.vue +++ b/src/components/core/DpEditor/DpRecommendationModal.vue @@ -89,6 +89,11 @@ export default { segmentId: { type: String, required: true + }, + + similarRecommendationsRoute: { + type: String, + required: true } }, @@ -212,7 +217,7 @@ export default { }, fetchSimilarRecommendations () { - const url = Routing.generate('api_resource_list', { resourceType: 'StatementSegment' }) + const url = this.similarRecommendationsRoute const params = { include: 'parentStatement,parentStatement.procedure', fields: { diff --git a/src/components/core/DpEditor/DpUploadModal.vue b/src/components/core/DpEditor/DpUploadModal.vue index 692dd5dd1..ace544463 100644 --- a/src/components/core/DpEditor/DpUploadModal.vue +++ b/src/components/core/DpEditor/DpUploadModal.vue @@ -17,6 +17,7 @@ @@ -37,6 +37,8 @@ import { prefixClassMixin } from '../../../mixins' export default { name: 'DpUploadedFile', + inject: ['getFileByHash'], + mixins: [prefixClassMixin], props: { diff --git a/src/components/core/DpUpload/utils/GetFileIdsByHash.js b/src/components/core/DpUpload/utils/GetFileIdsByHash.js index ab78108df..ad05cd589 100644 --- a/src/components/core/DpUpload/utils/GetFileIdsByHash.js +++ b/src/components/core/DpUpload/utils/GetFileIdsByHash.js @@ -7,9 +7,9 @@ import { dpApi } from '../../../../lib' * * @returns {Array} */ -function getFileIdsByHash (hashes) { +function getFileIdsByHash (hashes, route) { return dpApi.get( - Routing.generate('api_resource_list', { resourceType: 'File' }), + route, { filter: { hasHash: {