component def update
This commit is contained in:
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
## Simple calculator
|
## Simple calculator
|
||||||
|
|
||||||
> nuget source //code.sharp8n.com/api/packages/Sharp8N/nuget/index.json
|
|
||||||
> nuget package S8n.Components.Basics
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
code: basics.calculator
|
code: basics.calculator
|
||||||
description: Do simple operations for numbers in `args` input.
|
description: Do simple operations for numbers in `args` input.
|
||||||
@@ -13,57 +10,8 @@ inputs:
|
|||||||
- args: object[]
|
- args: object[]
|
||||||
outputs:
|
outputs:
|
||||||
- result: object
|
- result: object
|
||||||
|
source: S8n.Components.Packages (project)
|
||||||
class: S8n.Components.Basics.Calculator
|
class: S8n.Components.Basics.Calculator
|
||||||
methods: Calc()
|
methods: Calc()
|
||||||
```
|
gui: CalculatorComponent.vue
|
||||||
|
|
||||||
## Generic version
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
code: basics.calculator<T>
|
|
||||||
description: Do simple operations for numbers in `args` input. T typeof INumberBase<>
|
|
||||||
inputs:
|
|
||||||
- operator: string enum { add, subtract, multiply, divide }
|
|
||||||
- args: T[]
|
|
||||||
outputs:
|
|
||||||
- result: T
|
|
||||||
class: S8n.Components.Basics.Calculator<T>
|
|
||||||
methods: Calc()
|
|
||||||
```
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<template>
|
|
||||||
<q-card class="s8n-calculator">
|
|
||||||
<q-select
|
|
||||||
outlined
|
|
||||||
v-model="inputs.operator"
|
|
||||||
label="Operator"
|
|
||||||
:options="['add', 'subtract', 'multiply', 'divide']"
|
|
||||||
/>
|
|
||||||
<q-input outlined v-model="inputs.arg[0]" label="Arg1" />
|
|
||||||
<q-input outlined v-model="inputs.arg[1]" label="Arg2" />
|
|
||||||
|
|
||||||
<label>Result is: {{ outputs.result }}</label>
|
|
||||||
|
|
||||||
<q-btn
|
|
||||||
color="primary"
|
|
||||||
@click="execute('Calc')"
|
|
||||||
size="lg"
|
|
||||||
icon="mdi-calculator"
|
|
||||||
></q-btn>
|
|
||||||
</q-card>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { runtime } from "src/components/s8n-runtime";
|
|
||||||
|
|
||||||
const { execute, outputs, inputs } = runtime.createExecutor(
|
|
||||||
"S8n.Components.Basics.Calculator",
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
<style lang="scss">
|
|
||||||
.s8n-calculator {
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user