-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refs T31492): refactor editor (#104)
* 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
1 parent
4aa2242
commit 74890be
Showing
9 changed files
with
60 additions
and
916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
Oops, something went wrong.