Files
speckle-server/packages/frontend-2/components/project/page/automation/Functions.vue
T
andrewwallacespeckle c2a95b484f refactor(ui-components): define and use new font styles (#2524)
* New Text Styles. Initial FE2 changes

* More fe2 styling classes

* Minor update

* Minor update

* Fix build

* More updates for discussion

* More styling updates

* Minor updates to inputs

* More text updates

* More font class swapping

* Revert dui3 changes

* Confirmed Lineheights

* Add story files for new text styles

* Minor copy changes

* Minor typo

* andrew/web-1371-misalignment-in-account-dropdown

* andrew/web-1374-settings-text-styles-are-not-right

* andrew/web-1375-nav-texts-should-be-14px

* andrew/web-1376-decrease-size-of-versions-header

* andrew/web-1377-version-card-title

* semibold>medium

* Measure mode

* Changes from PR

* Tweaked nav menu

* Revert prose change. Add prose-sm

---------

Co-authored-by: Mike Tasset <mike.tasset@gmail.com>
2024-07-30 15:06:48 +01:00

99 lines
2.7 KiB
Vue

<template>
<div class="col-span-1">
<h2 class="h6 font-medium mb-6">Function</h2>
<AutomateFunctionCardView v-if="functions.length" vertical>
<AutomateFunctionCard
v-for="fn in functions"
:key="fn.fn.id"
:fn="fn.fn"
:is-outdated="isOutdated(fn)"
show-edit
@edit="onEdit(fn.fn)"
/>
</AutomateFunctionCardView>
<CommonGenericEmptyState
v-else
message="No valid functions are associated with this automation"
/>
<ProjectPageAutomationFunctionSettingsDialog
v-model:open="dialogOpen"
:project-id="projectId"
:automation-id="automation.id"
:revision-fn="dialogFunction"
:revision="automation.currentRevision"
/>
</div>
</template>
<script setup lang="ts">
import type { Optional } from '@speckle/shared'
import { graphql } from '~/lib/common/generated/gql'
import type {
AutomationsFunctionsCard_AutomateFunctionFragment,
ProjectPageAutomationFunctionSettingsDialog_AutomationRevisionFunctionFragment,
ProjectPageAutomationFunctions_AutomationFragment
} from '~/lib/common/generated/gql/graphql'
type EditableFunction = AutomationsFunctionsCard_AutomateFunctionFragment
type EditableFunctionRevision =
ProjectPageAutomationFunctionSettingsDialog_AutomationRevisionFunctionFragment
graphql(`
fragment ProjectPageAutomationFunctions_Automation on Automation {
id
currentRevision {
id
...ProjectPageAutomationFunctionSettingsDialog_AutomationRevision
functions {
release {
id
function {
id
...AutomationsFunctionsCard_AutomateFunction
releases(limit: 1) {
items {
id
}
}
}
}
...ProjectPageAutomationFunctionSettingsDialog_AutomationRevisionFunction
}
}
}
`)
const props = defineProps<{
projectId: string
automation: ProjectPageAutomationFunctions_AutomationFragment
}>()
const dialogOpen = ref(false)
const dialogFunction = ref<Optional<EditableFunctionRevision>>()
const functionRevisions = computed(
() => props.automation.currentRevision?.functions || []
)
const functions = computed(
() =>
functionRevisions.value.map((f) => ({
fn: f.release.function,
fnReleaseId: f.release.id
})) || []
)
const onEdit = (fn: EditableFunction) => {
const fid = fn.id
const revision = functionRevisions.value.find((f) => f.release.function.id === fid)
if (revision) {
dialogOpen.value = true
dialogFunction.value = revision
}
}
const isOutdated = (fn: (typeof functions.value)[0]) => {
const latestRelease = fn.fn.releases.items[0]
return latestRelease.id !== fn.fnReleaseId
}
</script>