Skip to content

Commit

Permalink
feat: new create function tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Sep 7, 2021
1 parent 9a24988 commit 0203f69
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.15.0",
"@babel/eslint-parser": "^7.15.4",
"cross-env": "^7.0.2",
"electron": "^14.0.0",
"electron-builder": "^22.11.7",
Expand All @@ -122,7 +122,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^7.17.0",
"sass": "^1.38.2",
"sass": "^1.39.0",
"sass-loader": "^10.2.0",
"standard-version": "^9.3.1",
"stylelint": "^13.13.1",
Expand Down
10 changes: 6 additions & 4 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,12 @@ export class MySQLClient extends AntaresCore {
* @memberof MySQLClient
*/
async createFunction (params) {
const parameters = params.parameters.reduce((acc, curr) => {
acc.push(`\`${curr.name}\` ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
return acc;
}, []).join(',');
const parameters = 'parameters' in params
? params.parameters.reduce((acc, curr) => {
acc.push(`\`${curr.name}\` ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
return acc;
}, []).join(',')
: '';

const body = params.returns ? params.sql : 'BEGIN\n RETURN 0;\nEND';

Expand Down
4 changes: 2 additions & 2 deletions src/main/libs/clients/PostgreSQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ export class PostgreSQLClient extends AntaresCore {
async createRoutine (routine) {
const parameters = 'parameters' in routine
? routine.parameters.reduce((acc, curr) => {
acc.push(`${curr.context} ${curr.name} ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
acc.push(`${curr.context} ${curr.name} ${curr.type}`);
return acc;
}, []).join(',')
: '';
Expand Down Expand Up @@ -887,7 +887,7 @@ export class PostgreSQLClient extends AntaresCore {
async createFunction (func) {
const parameters = 'parameters' in func
? func.parameters.reduce((acc, curr) => {
acc.push(`${curr.context} ${curr.name || ''} ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
acc.push(`${curr.context} ${curr.name || ''} ${curr.type}`);
return acc;
}, []).join(',')
: '';
Expand Down
28 changes: 28 additions & 0 deletions src/renderer/components/Workspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@
</span>
</a>

<a
v-else-if="tab.type === 'new-function'"
class="tab-link"
:class="{'badge': tab.isChanged}"
>
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
{{ $t('message.newFunction') }}
<span
class="btn btn-clear"
:title="$t('word.close')"
@mousedown.left.stop
@click.stop="closeTab(tab)"
/>
</span>
</a>

<a
v-else-if="tab.type.includes('temp-')"
class="tab-link"
Expand Down Expand Up @@ -344,6 +361,15 @@
:routine="tab.elementName"
:schema="tab.schema"
/>
<WorkspaceTabNewFunction
v-else-if="tab.type === 'new-function'"
:key="tab.uid"
:tab="tab"
:connection="connection"
:is-selected="selectedTab === tab.uid"
:trigger="tab.elementName"
:schema="tab.schema"
/>
<WorkspaceTabPropsFunction
v-else-if="['temp-function-props', 'function-props'].includes(tab.type)"
:key="tab.uid"
Expand Down Expand Up @@ -391,6 +417,7 @@ import WorkspaceTabNewTable from '@/components/WorkspaceTabNewTable';
import WorkspaceTabNewView from '@/components/WorkspaceTabNewView';
import WorkspaceTabNewTrigger from '@/components/WorkspaceTabNewTrigger';
import WorkspaceTabNewRoutine from '@/components/WorkspaceTabNewRoutine';
import WorkspaceTabNewFunction from '@/components/WorkspaceTabNewFunction';
import WorkspaceTabPropsTable from '@/components/WorkspaceTabPropsTable';
import WorkspaceTabPropsView from '@/components/WorkspaceTabPropsView';
Expand Down Expand Up @@ -419,6 +446,7 @@ export default {
WorkspaceTabPropsTrigger,
WorkspaceTabPropsTriggerFunction,
WorkspaceTabNewRoutine,
WorkspaceTabNewFunction,
WorkspaceTabPropsRoutine,
WorkspaceTabPropsFunction,
WorkspaceTabPropsScheduler,
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/WorkspaceExploreBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
@open-create-view-tab="openCreateElementTab('view')"
@open-create-trigger-tab="openCreateElementTab('trigger')"
@open-create-routine-tab="openCreateElementTab('routine')"
@show-create-function-modal="showCreateFunctionModal"
@open-create-function-tab="openCreateElementTab('function')"
@show-create-trigger-function-modal="showCreateTriggerFunctionModal"
@show-create-scheduler-modal="showCreateSchedulerModal"
@reload="refresh"
Expand Down Expand Up @@ -118,7 +118,7 @@
:context-event="miscContextEvent"
@open-create-trigger-tab="openCreateElementTab('trigger')"
@open-create-routine-tab="openCreateElementTab('routine')"
@show-create-function-modal="showCreateFunctionModal"
@open-create-function-tab="openCreateElementTab('function')"
@show-create-trigger-function-modal="showCreateTriggerFunctionModal"
@show-create-scheduler-modal="showCreateSchedulerModal"
@close-context="closeMiscFolderContext"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div
v-if="selectedMisc === 'function'"
class="context-element"
@click="$emit('show-create-function-modal')"
@click="$emit('open-create-function-tab')"
>
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box text-light pr-1" /> {{ $t('message.createNewFunction') }}</span>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/WorkspaceExploreBarSchemaContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div
v-if="workspace.customizations.functionAdd"
class="context-element"
@click="showCreateFunctionModal"
@click="openCreateFunctionTab"
>
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box pr-1" /> {{ $tc('word.function', 1) }}</span>
</div>
Expand Down Expand Up @@ -144,8 +144,8 @@ export default {
openCreateRoutineTab () {
this.$emit('open-create-routine-tab');
},
showCreateFunctionModal () {
this.$emit('show-create-function-modal');
openCreateFunctionTab () {
this.$emit('open-create-function-tab');
},
showCreateTriggerFunctionModal () {
this.$emit('show-create-trigger-function-modal');
Expand Down
Loading

0 comments on commit 0203f69

Please sign in to comment.