Skip to content

Commit

Permalink
feat(refs T31492): refactor editor (#104)
Browse files Browse the repository at this point in the history
* feat(refs T31492): Remove modals for boilerplate and recommendation

We don't want any business logic here, so it is moved to demosplan and replaced with slots.

* feat(refs T31492): Remove deprecated props

They aren't used anymore. All occurrences were replaced with toolbarItems.

* feat(refs T31492): Add defaults for toolbar
  • Loading branch information
gruenbergerdemos authored Mar 1, 2023
1 parent 4aa2242 commit 74890be
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 916 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## UNRELEASED

### Changed

- ([#104](https://github.com/demos-europe/demosplan-ui/pull/104)) Add slots for modal and button in DpEditor ([@gruenbergerdemos](https://github.com/gruenbergerdemos))
- ([#104](https://github.com/demos-europe/demosplan-ui/pull/104)) Remove deprecated props in DpEditor ([@gruenbergerdemos](https://github.com/gruenbergerdemos))
- ([#104](https://github.com/demos-europe/demosplan-ui/pull/104)) Remove unnecessary routes in DpEditor ([@gruenbergerdemos](https://github.com/gruenbergerdemos))

### Fixed

- ([#111](https://github.com/demos-europe/demosplan-ui/pull/111)) Fix checkbox positioning in DpTableCardListHeader ([@muellerdemos](https://github.com/muellerdemos))
Expand Down
4 changes: 0 additions & 4 deletions src/components/core/DpEditor/DpBoilerPlate.stories.mdx

This file was deleted.

126 changes: 0 additions & 126 deletions src/components/core/DpEditor/DpBoilerPlate.vue

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/core/DpEditor/DpBoilerPlateModal.stories.mdx

This file was deleted.

147 changes: 0 additions & 147 deletions src/components/core/DpEditor/DpBoilerPlateModal.vue
Original file line number Diff line number Diff line change
@@ -1,147 +0,0 @@
<template>
<dp-modal
ref="boilerPlateModal"
content-classes="u-1-of-2">
<template>
<h3>{{ Translator.trans('boilerplate.insert') }}</h3>
<dp-boiler-plate
:title="Translator.trans('boilerplates.category', { category: Translator.trans(boilerPlateType) })"
:boiler-plates="displayedBoilerplates"
ref="boilerplateDropdown"
group-values="boilerplates"
group-label="groupName"
:group-select="false"
@boilerplate-text-added="addBoilerplateText" />
<div class="flex flex-items-center u-mt">
<a
v-if="boilerplateEditViewRoute"
class="weight--bold font-size-small"
:href="boilerplateEditViewRoute">
{{ Translator.trans('boilerplates.edit') }} ({{ Translator.trans('view.leave.hint') }})
</a>
<dp-button-row
class="flex-item-end"
primary
:primary-text="Translator.trans('insert')"
secondary
@primary-action="insertBoilerPlate"
@secondary-action="resetAndClose" />
</div>
</template>
</dp-modal>
</template>

<script>
import { mapActions, mapGetters, mapState } from 'vuex'
import DpBoilerPlate from './DpBoilerPlate'
import DpButtonRow from '../../DpButtonRow/DpButtonRow'
import DpModal from '../DpModal'
import { hasOwnProp } from '../../../utils'
export default {
name: 'DpBoilerPlateModal',
components: {
DpBoilerPlate,
DpButtonRow,
DpModal
},
props: {
// Needed to get boilerplates from BE via store
procedureId: {
required: true,
type: String
},
boilerPlateType: {
required: false,
type: String,
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,
default: ''
}
},
data () {
return {
// Needed to make sure boilerplates are loaded from the BE before <dp-boiler-plate> component is mounted
boilerPlatesLoaded: false,
// The boilerplate text emitted from dp-boiler-plate, then emitted to TipTapTextEditor.vue on click of 'insert' button
textToBeAdded: ''
}
},
computed: {
...mapState('boilerplates', ['getBoilerplatesRequestFired', 'moduleRegistered']),
...mapGetters('boilerplates', ['getGroupedBoilerplates']),
displayedBoilerplates () {
const displayed = JSON.parse(JSON.stringify(this.getGroupedBoilerplates))
displayed.forEach(group => {
if (this.boilerPlateType !== '') {
if (typeof this.boilerPlateType === 'string') {
group.boilerplates = group.boilerplates.filter(bp => bp.category.includes(this.boilerPlateType))
} else if (Array.isArray(this.boilerPlateType)) {
group.boilerplates = group.boilerplates.filter(bp => this.boilerPlateType.some(el => bp.category.includes(el)))
}
}
})
return displayed
},
displayedBoilerplateType () {
let boilerplateString = ''
if (typeof this.boilerPlateType === 'string') {
boilerplateString = Translator.trans(this.boilerPlateType)
} else if (Array.isArray(this.boilerPlateType)) {
boilerplateString = this.boilerPlateType.map(bp => Translator.trans(bp)).join(', ')
}
return boilerplateString
}
},
methods: {
...mapActions('boilerplates', ['getBoilerPlates']),
addBoilerplateText (textFromTextArea) {
this.textToBeAdded = textFromTextArea
},
insertBoilerPlate () {
this.$emit('insertBoilerPlate', this.textToBeAdded)
this.resetAndClose()
},
resetAndClose () {
this.$refs.boilerplateDropdown.resetBoilerPlateMultiSelect()
this.toggleModal()
},
toggleModal () {
this.$refs.boilerPlateModal.toggle()
}
},
created () {
if (this.getBoilerplatesRequestFired === false) {
this.getBoilerPlates(this.procedureId)
}
}
}
</script>
Loading

0 comments on commit 74890be

Please sign in to comment.