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

F t31116 demosplan UI no longer use routing #91

Merged
merged 56 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ff4de38
chore (refs T31116): Add Routes Props for DpDashboardTaskCard.
ahmad-demos Jan 30, 2023
d7329b8
chore (refs T31116): Add fileRoute Props instead of string.
ahmad-demos Jan 30, 2023
bb3ff53
chore (refs T31116): Add fileRoute Props instead of string.
ahmad-demos Jan 30, 2023
a6b53e3
chore (refs T31116): Add fileRoute Props instead of string.
ahmad-demos Jan 30, 2023
395a417
chore (refs T31116): Add fileRoute Props instead of string.
ahmad-demos Jan 30, 2023
25f8d2a
chore (refs T31116): Add Routes Props instead of string.
ahmad-demos Jan 30, 2023
cab5e33
chore (refs T31116): Add param instead of route string.
ahmad-demos Jan 31, 2023
1095c03
chore (refs T31116): Add boilerplateListRoute Prop for Editor instead…
ahmad-demos Jan 31, 2023
f3a4e1a
chore (refs T31116): Add boilerplateListRoute Prop for Editor instead…
ahmad-demos Jan 31, 2023
c855277
chore (refs T31116): Add similarRecommendationsRoute Prop for Editor …
ahmad-demos Jan 31, 2023
104e2b5
chore (refs T31116): Add similarRecommendationsRoute Prop for Editor …
ahmad-demos Jan 31, 2023
6f5b8b1
chore (refs T31116): Add route param for dpRpc.
ahmad-demos Jan 31, 2023
ad1afe6
chore (refs T31116): move all Routing.generate to core.
ahmad-demos Feb 1, 2023
b6404ac
chore (refs T31116): revert changes for dpRpc.
ahmad-demos Feb 1, 2023
0b6cba1
chore (refs T31116): move Routing.generate to core.
ahmad-demos Feb 1, 2023
98fdabd
chore (refs T31116): move Routing.generate to core.
ahmad-demos Feb 1, 2023
ca229db
chore (refs T31116): move Routing.generate to core.
ahmad-demos Feb 1, 2023
1c4e829
chore (refs T31116): move Routing.generate to core.
ahmad-demos Feb 1, 2023
d7d1be9
chore (refs T31116): Add routes prop that contains all routes.
ahmad-demos Feb 1, 2023
54d9444
chore (refs T31116): revert all the changes for DpDashboardTaskCard.
ahmad-demos Feb 1, 2023
3784acc
chore (refs T31116): Change Prop name for edit boilerplate route.
ahmad-demos Feb 3, 2023
4c17057
chore (refs T31116): add separate props to parent prop (routes).
ahmad-demos Feb 3, 2023
2783e7d
chore (refs T31116): Add parent prop (routes) for separate props.
ahmad-demos Feb 3, 2023
5855c9d
Merge branch 'main' into f_T31116_demosplan_ui_no_longer_use_routing
ahmad-demos Feb 7, 2023
f998847
chore (refs T31116): WIP: minor improvements JS code, add provide inj…
ahmad-demos Feb 8, 2023
551eeab
chore (refs T31116): Changes in package.json
ahmad-demos Feb 8, 2023
3a51670
chore (refs T31116): minor improvements JS.
ahmad-demos Feb 8, 2023
462e0e5
chore (refs T31116): minor improvements JS.
ahmad-demos Feb 8, 2023
1bb59b6
chore (refs T31116): minor improvements JS.
ahmad-demos Feb 8, 2023
7fb3fad
chore (refs T31116): rename prop for upload file & minor improvements…
ahmad-demos Feb 8, 2023
82e69ec
chore (refs T31116): WIP: minor improvements in route for DpAutocompl…
ahmad-demos Feb 9, 2023
ed7308b
chore (refs T31116): minor improvements in route for DpAutocomplete.
ahmad-demos Feb 9, 2023
d20932a
Update src/components/core/DpEditor/DpBoilerPlateModal.vue
ahmad-demos Feb 10, 2023
9fcdfbc
Update src/components/core/DpEditor/DpEditor.vue
ahmad-demos Feb 10, 2023
cd139e8
Update src/components/core/DpEditor/DpEditor.vue
ahmad-demos Feb 10, 2023
ecb50ce
chore (refs T31116): rename prop to make that clear, because prop as …
ahmad-demos Feb 10, 2023
9c74850
chore (refs T31116): remove default value, when prop required is true.
ahmad-demos Feb 10, 2023
8f7bf80
chore (refs T31116): rename boilerplate route prop.
ahmad-demos Feb 10, 2023
031f9e6
chore (refs T31116): remove unused prop.
ahmad-demos Feb 10, 2023
39b6d09
chore (refs T31116): add required true to route prop.
ahmad-demos Feb 10, 2023
db654ec
chore (refs T31116): WIP: revert changes in validator.
ahmad-demos Feb 10, 2023
391f33b
chore (refs T31116): WIP: revert changes in required.
ahmad-demos Feb 10, 2023
57ffba6
chore (refs T31116): update Changelog.
ahmad-demos Feb 10, 2023
e96471b
Update CHANGELOG.md
ahmad-demos Feb 10, 2023
61dec86
chore (refs T31116): revert all changes in DpRegisterFlyout.
ahmad-demos Feb 10, 2023
5873380
chore (refs T31116): revert all changes in package.json
ahmad-demos Feb 10, 2023
3f86088
chore (refs T31116): WIP: make routes required as true.
ahmad-demos Feb 10, 2023
8c7cfab
chore (refs T31116): minor improvements in routes prop condition.
ahmad-demos Feb 10, 2023
829f74b
chore (refs T31116): revert required false for routes prop.
ahmad-demos Feb 10, 2023
a4221b3
chore (refs T31116): revert package.json
ahmad-demos Feb 13, 2023
31890c2
Merge branch 'main' into f_T31116_demosplan_ui_no_longer_use_routing
ahmad-demos Feb 13, 2023
b0db63b
Merge branch 'main' into f_T31116_demosplan_ui_no_longer_use_routing
ahmad-demos Feb 13, 2023
2b50a4c
Merge branch 'main' into f_T31116_demosplan_ui_no_longer_use_routing
ahmad-demos Feb 20, 2023
fc401f5
Merge branch 'main' into f_T31116_demosplan_ui_no_longer_use_routing
ahmad-demos Feb 21, 2023
8d194ed
chore (refs T31116): edit comment.
ahmad-demos Feb 21, 2023
4e4acde
Merge remote-tracking branch 'origin/f_T31116_demosplan_ui_no_longer_…
ahmad-demos Feb 21, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
19 changes: 4 additions & 15 deletions src/components/core/DpAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export default {
mixins: [prefixClassMixin],

props: {
additionalRouteParams: {
type: Object,
required: false,
default: () => ({})
},

height: {
type: String,
required: false,
Expand All @@ -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
},

Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/components/core/DpEditor/DpBoilerPlateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@boilerplate-text-added="addBoilerplateText" />
<div class="flex flex-items-center u-mt">
<a
class="weight--bold font-size-small"
:href="Routing.generate('DemosPlan_procedure_boilerplate_list', { procedure: procedureId })">
v-if="boilerplateEditViewRoute"
salisdemos marked this conversation as resolved.
Show resolved Hide resolved
class="weight--bold font-size-small"
:href="boilerplateEditViewRoute">
{{ Translator.trans('boilerplates.edit') }} ({{ Translator.trans('view.leave.hint') }})
</a>
<dp-button-row
Expand Down Expand Up @@ -59,6 +60,16 @@ export default {
default: ''
},

/**
* Route to a view that allows editing the available boilerplates
* Displayed as a link at the bottom of the modal
*/
boilerplateEditViewRoute: {
required: false,
type: String,
default: ''
},

editorId: {
required: false,
type: String,
Expand Down
30 changes: 28 additions & 2 deletions src/components/core/DpEditor/DpEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
v-if="toolbar.boilerPlate && boilerPlateEnabled"
ref="boilerPlateModal"
:editor-id="editorId"
:boilerplate-edit-view-route="routes.boilerplateEditViewRoute"
:procedure-id="procedureId"
:boiler-plate-type="toolbar.boilerPlate"
@insertBoilerPlate="text => handleInsertText(text)" />
Expand All @@ -18,6 +19,7 @@
<dp-upload-modal
v-if="toolbar.imageButton"
ref="uploadModal"
:get-file-by-hash="routes.getFileByHash"
@insert-image="insertImage"
@add-alt="addAltTextToImage"
@close="resetEditingImage" />
Expand All @@ -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" />
<div :class="prefixClass('row tiptap')">
<div :class="prefixClass('col')">
<div
Expand Down Expand Up @@ -577,6 +580,29 @@ export default {
default: false
},

/**
* boilerplateEditViewRoute: (Optional) route to a view that allows editing
* boilerplates. Displayed as a link at the bottom of the boilerplate modal, if
* toolbar.boilerplate is set
* getFileByHash: (Required) function that receives a file hash as parameter
hwiem marked this conversation as resolved.
Show resolved Hide resolved
* and returns a route to that file. Used for displaying images.
* similarRecommendationsRoute: (Optional) route to fetch similar
* recommendations (needed if toolbar.recommendationButton is set to
* true)
*/
routes: {
type: Object,
required: false,
hwiem marked this conversation as resolved.
Show resolved Hide resolved
default: () => ({}),
validator: (prop) => {
return Object.keys(prop).every(key => [
'boilerplateEditViewRoute',
'getFileByHash',
'similarRecommendationsRoute'
].includes(key))
}
},

segmentId: {
type: String,
required: false,
Expand Down Expand Up @@ -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 `<img src="${Routing.generate('core_file', { hash: imageHash })}" width="${imageWidth}" height="${imageHeight}" alt="${altText}">`
return `<img src="${this.routes.getFileByHash(imageHash)}" width="${imageWidth}" height="${imageHeight}" alt="${altText}">`
})
} catch (e) {
return text
Expand Down
7 changes: 6 additions & 1 deletion src/components/core/DpEditor/DpRecommendationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export default {
segmentId: {
type: String,
required: true
},

similarRecommendationsRoute: {
type: String,
required: true
}
},

Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 9 additions & 1 deletion src/components/core/DpEditor/DpUploadModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<dp-upload-files
allowed-file-types="img"
id="imageFile"
:get-file-by-hash="getFileByHash"
:max-file-size="20 * 1024 * 1024/* 20 MiB */"
:max-number-of-files="1"
ref="uploader"
Expand Down Expand Up @@ -63,6 +64,13 @@ export default {
DpUploadFiles
},

props: {
getFileByHash: {
type: Function,
required: true
}
},

data () {
return {
fileUrl: '',
Expand Down Expand Up @@ -90,7 +98,7 @@ export default {
},

setFile ({ hash }) {
this.fileUrl = Routing.generate('core_file', { hash: hash })
this.fileUrl = this.getFileByHash(hash)
// Force-update the component so that DpModal updates and therefore check for new focusable elements
this.$forceUpdate()
},
Expand Down
11 changes: 11 additions & 0 deletions src/components/core/DpUpload/DpUploadFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export default {

mixins: [prefixClassMixin],

provide () {
return {
getFileByHash: this.getFileByHash
}
},

props: {
/**
* Array of mimeTypes or a defined preset as String
Expand Down Expand Up @@ -88,6 +94,11 @@ export default {
default: false
},

getFileByHash: {
type: Function,
required: true
},

id: {
type: String,
required: false,
Expand Down
4 changes: 3 additions & 1 deletion src/components/core/DpUpload/DpUploadedFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</span>
<span v-if="isImage">
<img
:src="Routing.generate('core_file', { hash: file.hash })"
:src="getFileByHash(file.hash)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should try to avoid using any type of generate route within demosplan-ui. We better should pass the generated src.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here no more using Routing.generate within demosplan-ui!

Copy link
Contributor

@salisdemos salisdemos Feb 10, 2023

Choose a reason for hiding this comment

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

sorry. I wrote it wrong. What I ment was "making api-requests"

Copy link
Contributor

Choose a reason for hiding this comment

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

but we can leave it like it is by now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@salisdemos this request is needed to show image thumbs of images that are already uploaded. how would you solve this without api requests?

Copy link
Contributor

Choose a reason for hiding this comment

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

As I said. I am fine with leaving like it iss - by now.
But we have to find a way to handle that. I think we don't need dpApi here in the end, if we build a way to pass the generated thumbnails.
But if we leave it like it is now, who ever uses this has to use the logic from "getFileByHash" to use the uploader / generate a image-url. That feels too coupled for me.

:aria-label="Translator.trans('image.preview')"
width="50px">
</span>
Expand Down Expand Up @@ -37,6 +37,8 @@ import { prefixClassMixin } from '../../../mixins'
export default {
name: 'DpUploadedFile',

inject: ['getFileByHash'],

mixins: [prefixClassMixin],

props: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/core/DpUpload/utils/GetFileIdsByHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { dpApi } from '../../../../lib'
*
* @returns {Array<Ids>}
*/
function getFileIdsByHash (hashes) {
function getFileIdsByHash (hashes, route) {
return dpApi.get(
Routing.generate('api_resource_list', { resourceType: 'File' }),
route,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should rework this one separately. This logic isn't generic enough. Maybe this even doesn't belong here bot in the core

{
filter: {
hasHash: {
Expand Down