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

Add text annotation block to workflows #1804

Merged
merged 1 commit into from
May 30, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/web/workflow/public/icons/dark/text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/web/workflow/public/icons/text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions client/web/workflow/src/components/Configurator/Text.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<c-rich-text-input
v-model="label"
:labels="{
urlPlaceholder: $t('content.urlPlaceholder'),
ok: $t('content.ok'),
openLinkInNewTab: $t('content.openLinkInNewTab'),
}"
class="m-3"
@input="$emit('update-value', $event)"
/>
</template>

<script>
import base from './base'
import { components } from '@cortezaproject/corteza-vue'
const { CRichTextInput } = components

export default {
components: {
CRichTextInput,
},

extends: base,

computed: {
label: {
get () {
return this.item.node.value
},

set (label) {
this.item.node.value = label
},
},
},
}
</script>
8 changes: 7 additions & 1 deletion client/web/workflow/src/components/Configurator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class="d-flex flex-column"
>
<b-card
v-if="kind !== 'Text'"
class="flex-grow-1 border-bottom border-light rounded-0"
>
<b-card-header
Expand Down Expand Up @@ -32,6 +33,7 @@
:edges.sync="edges"
:out-edges="outEdges"
:is-subworkflow="isSubworkflow"
@update-value="$emit('update-value', $event)"
@update-default-value="updateDefaultName"
/>
</div>
Expand Down Expand Up @@ -64,7 +66,7 @@ export default {
},

kind () {
const { kind } = this.item.config
const { kind, ref } = this.item.config

if (kind === 'exec-workflow') {
return 'ExecWorkflow'
Expand All @@ -74,6 +76,10 @@ export default {
return 'ErrorHandler'
}

if (kind === 'visual' && ref === 'text') {
return 'Text'
}

if (kind) {
return kind.charAt(0).toUpperCase() + kind.slice(1)
}
Expand Down
1 change: 1 addition & 0 deletions client/web/workflow/src/components/Configurator/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { default as Prompt } from './Prompt'
export { default as Delay } from './Delay'
export { default as ExecWorkflow } from './ExecWorkflow'
export { default as ErrorHandler } from './ErrorHandler'
export { default as Text } from './Text'
54 changes: 34 additions & 20 deletions client/web/workflow/src/components/WorkflowEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ export default {
this.graph.setConnectable(true)
this.graph.setAllowDanglingEdges(false)
this.graph.setTooltips(true)

/* eslint-disable no-new */
new mxRubberband(this.graph) // Enables multiple selection
this.graph.edgeLabelsMovable = false
Expand Down Expand Up @@ -906,6 +907,7 @@ export default {
const vertex = this.vertices[cell.id]
const { kind } = vertex.config
const { style } = vertex.node

if (vertex && kind !== 'visual') {
const icon = this.getIcon(getStyleFromKind(vertex.config).icon, this.currentTheme)
const type = this.$t(`steps:${style}.short`)
Expand Down Expand Up @@ -1057,7 +1059,7 @@ export default {
values +
'</div>'
} else {
label = `<div id="openSidebar" class="d-flex"><span class="d-inline-block mb-0 text-truncate">${encodeHTML(cell.value || '')}</span></div>`
label = cell.value
}
}

Expand Down Expand Up @@ -1115,6 +1117,8 @@ export default {
value = style.split('gateway')[1]
} else if (style === 'expressions') {
value = 'Define and mutate scope variables'
} else if (style === 'text') {
value = 'Text here'
}

const cell = new mxCell(
Expand Down Expand Up @@ -1584,15 +1588,22 @@ export default {
this.graph.addListener(mxEvent.CELLS_ADDED, (sender, evt) => {
if (!this.rendering) {
const cells = evt.getProperty('cells')
let lastVertexID = null
cells.forEach(cell => {
if (cell && cell.vertex) {
if (!this.rendering) {
cell.defaultName = true
this.addCellToVertices(cell)
this.graph.setSelectionCells([cell])
lastVertexID = cell.id
}
}
})

if (lastVertexID) {
const vertex = this.vertices[lastVertexID]
this.sidebarReopen(vertex, vertex.config.kind)
}
}
})

Expand Down Expand Up @@ -1636,21 +1647,6 @@ export default {
})
})

this.graph.addListener(mxEvent.DOUBLE_CLICK, (sender, evt) => {
const event = evt.getProperty('event')
const cell = evt.getProperty('cell')
if (event && cell) {
const isVisual = ((this.vertices[cell.id] || {}).config || {}).kind === 'visual'
if (cell.edge || isVisual) {
const item = cell.edge ? this.edges[cell.id] : this.vertices[cell.id]
const itemType = cell.edge ? 'edge' : item.config.kind
this.sidebarReopen(item, itemType)
}
}

evt.consume()
})

// Zoom event
mxEvent.addMouseWheelListener((event, up) => {
if (mxEvent.isConsumed(event)) {
Expand Down Expand Up @@ -1706,9 +1702,10 @@ export default {
// Prevent sidebar opening/closing when CTRL(CMD) is pressed while clicking
} else if (cell) {
// If clicked on Cog icon
if (event.target.id === 'openSidebar') {
const item = cell.edge ? this.edges[cell.id] : this.vertices[cell.id]
const itemType = cell.edge ? 'edge' : item.config.kind
const item = cell.edge ? this.edges[cell.id] : this.vertices[cell.id]
const itemType = cell.edge ? 'edge' : item.config.kind

if (event.target.id === 'openSidebar' || item.config.kind === 'visual') {
this.sidebarReopen(item, itemType)
} else if (event.target.id === 'openIssues') {
this.issuesModal.issues = this.issues[cell.id]
Expand Down Expand Up @@ -1758,6 +1755,8 @@ export default {
mxConstants.GUIDE_STROKEWIDTH = 1

// Creates the default style for vertices
const defaultStyle = this.graph.getStylesheet().getDefaultVertexStyle()

let style = this.graph.getStylesheet().getDefaultVertexStyle()
style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_RECTANGLE
style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter
Expand Down Expand Up @@ -1801,6 +1800,21 @@ export default {
style[mxConstants.STYLE_STROKEWIDTH] = 0
style[mxConstants.STYLE_STROKEWIDTH] = 2
this.graph.getStylesheet().putCellStyle('swimlane', style)

// Text
style = {}
style[mxConstants.STYLE_RESIZABLE] = true
style[mxConstants.STYLE_CONNECTABLE] = false
style[mxConstants.STYLE_FILLCOLOR] = 'var(--white)'
style[mxConstants.STYLE_STROKECOLOR] = 'var(--extra-light)'
style[mxConstants.STYLE_STROKEWIDTH] = 1
style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_TOP
style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_LEFT
style[mxConstants.STYLE_SPACING_TOP] = 10
style[mxConstants.STYLE_SPACING_LEFT] = 10
style[mxConstants.STYLE_WHITE_SPACE] = 'wrap'
style[mxConstants.STYLE_OVERFLOW] = 'hidden'
this.graph.getStylesheet().putCellStyle('text', style)
},

translateCell (style) {
Expand Down Expand Up @@ -1835,7 +1849,7 @@ export default {
}

const { cell } = terminal
let isConnectable = this.model.isVertex(cell) && !cell.style.includes('swimlane')
let isConnectable = this.model.isVertex(cell) && !['swimlane', 'text'].includes(cell.style)

// Only one outbound connection per trigger
if (cell.style.includes('trigger') && cell.edges) {
Expand Down
36 changes: 36 additions & 0 deletions client/web/workflow/src/components/faIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ import {
faFileExport,
faToggleOn,
faToggleOff,
faBold,
faItalic,
faUnderline,
faStrikethrough,
faQuoteRight,
faCode,
faListUl,
faListOl,
faOutdent,
faIndent,
faAlignLeft,
faAlignCenter,
faAlignRight,
faAlignJustify,
faLink,
faRemoveFormat,
faParagraph,
faTasks,
} from '@fortawesome/free-solid-svg-icons'

import {
Expand Down Expand Up @@ -72,4 +90,22 @@ library.add(
faToggleOff,
faAngleUp,
faAngleDown,
faBold,
faItalic,
faUnderline,
faStrikethrough,
faQuoteRight,
faCode,
faListUl,
faListOl,
faOutdent,
faIndent,
faAlignLeft,
faAlignCenter,
faAlignRight,
faAlignJustify,
faLink,
faRemoveFormat,
faParagraph,
faTasks,
)
9 changes: 9 additions & 0 deletions client/web/workflow/src/lib/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ const kindToStyle = {
icon: 'debug',
style: 'debug',
},

visualText: {
width: 400,
height: 250,
icon: 'text',
style: 'text',
},
}

// When adding & or copy/pasting a new cell, this is used to determine the kind & ref
Expand Down Expand Up @@ -167,6 +174,8 @@ export function getKindFromStyle (vertex) {
}
} else if (kind === 'swimlane') {
return { kind: 'visual', ref: 'swimlane' }
} else if (kind === 'text') {
return { kind: 'visual', ref: 'text' }
} else {
return { kind }
}
Expand Down
4 changes: 4 additions & 0 deletions client/web/workflow/src/lib/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default [
kind: 'visual',
ref: 'swimlane',
},
{
kind: 'visual',
ref: 'text',
},
{
kind: 'hr',
},
Expand Down
8 changes: 0 additions & 8 deletions lib/vue/src/components/input/CRichTextInput/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ export default {
},
onUpdate: this.onUpdate,
})

/**
* Since we migrated to TipTap, the new content should be emitted
* after tiptap is done parsing it.
*/
this.$nextTick(() => {
this.onUpdate()
})
},

/**
Expand Down
6 changes: 5 additions & 1 deletion locale/en/corteza-webapp-workflow/steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ trigger:
short: Trigger
tooltip: Trigger the workflow execution based on configuration
tooltip:
configure-step: Configure step
configure-step: Configure step
text:
label: Text
short: Text
tooltip: Text block used for annotations
Loading