From 454e9cbdb392f13e323c60a41a0d057dbdd750ed Mon Sep 17 00:00:00 2001 From: "Idmar Ramos Jr. (Id)" Date: Sun, 28 Nov 2021 18:15:31 +0100 Subject: [PATCH 01/54] Raw markup to add sections to logical sidebar Keep in mind this is a raw quick and dirty markup. The objective is help us to udnerstand how all elements work together. --- app/angular/logic/sidebar-panel.html | 132 +++++++++++++++++++++++++++ app/sass/app.scss | 3 +- app/sass/sidebarPannel.scss | 104 +++++++++++++++++++++ 3 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 app/angular/logic/sidebar-panel.html create mode 100644 app/sass/sidebarPannel.scss diff --git a/app/angular/logic/sidebar-panel.html b/app/angular/logic/sidebar-panel.html new file mode 100644 index 00000000..d7c6f134 --- /dev/null +++ b/app/angular/logic/sidebar-panel.html @@ -0,0 +1,132 @@ + \ No newline at end of file diff --git a/app/sass/app.scss b/app/sass/app.scss index 534cece9..4c0e19e1 100644 --- a/app/sass/app.scss +++ b/app/sass/app.scss @@ -11,4 +11,5 @@ @import 'selectOptions.scss'; @import 'sql.scss'; @import 'print.scss'; -@import 'joint-custom.scss'; \ No newline at end of file +@import 'joint-custom.scss'; +@import 'sidebarPannel'; \ No newline at end of file diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss new file mode 100644 index 00000000..0ef8d661 --- /dev/null +++ b/app/sass/sidebarPannel.scss @@ -0,0 +1,104 @@ +.sidebar-panel { + +} +//////////////////////////////////////////////////////////////////////////////// +// .panel-header +//////////////////////////////////////////////////////////////////////////////// + +.panel-header { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + padding: 8px 12px; + margin-bottom: 1px; + color: #fff; + background-color: #3d9970; + cursor: pointer; +} + +.panel-header:hover { + background-color: #1a744b; +} + +.panel-header > h3 { + font-weight: 300; + font-size: 14px; + margin: 0; +} + +.panel-header > .fa { + position: relative; + top: -2px; +} + +//////////////////////////////////////////////////////////////////////////////// +// .panel-content +//////////////////////////////////////////////////////////////////////////////// +.temp-hide .panel-content {padding: 0;} + +.panel-content { + padding: 8px 12px; +} + +//////////////////////////////////////////////////////////////////////////////// +// .table-columns +//////////////////////////////////////////////////////////////////////////////// +.table-columns { + list-style: none; + padding: 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// .column-details +//////////////////////////////////////////////////////////////////////////////// +.column-details.temp-expanded header {display: none;} + +.column-details { + padding: 12px 8px; + border: 1px solid #ddd; + border-radius: 3px; + margin-bottom: 8px; +} + +.column-details header { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + ; +} + +.column-details .table-title { + margin: 0; + font-size: 12px; + font-weight: bold; + font-family: monospace; +} + +.column-details .relationship { + display: inline-block; + border: 1px solid #000; + border-radius: 2px; + padding:0 2px; + font-size: 10px; + font-weight: 500; + letter-spacing: 0.1em; +} + +.column-details-content .form-group {margin-bottom: 12px;} + +//////////////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////////////// +.column-details-actions { + display: flex; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + border-top: 1px solid #ddd; + padding-top: 12px;; +} + +.column-details-actions .br-button {width: 50%;} \ No newline at end of file From 2e4f7e16c51124f166aa5212d8f1824bcff235d9 Mon Sep 17 00:00:00 2001 From: "Idmar Ramos Jr. (Id)" Date: Sun, 28 Nov 2021 18:17:16 +0100 Subject: [PATCH 02/54] Add missing line to comment header --- app/sass/buttons.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/sass/buttons.scss b/app/sass/buttons.scss index 208a9525..61bd6922 100644 --- a/app/sass/buttons.scss +++ b/app/sass/buttons.scss @@ -39,6 +39,8 @@ background-color: #ddd; } +//////////////////////////////////////////////////////////////////////////////// + // .btn-alt //////////////////////////////////////////////////////////////////////////////// .btn-alt { From 4dd16608c79452d9d8f919d0b6a82f7fd1b85f6d Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Wed, 1 Dec 2021 16:21:52 -0300 Subject: [PATCH 03/54] View form component WIP --- app/angular/index.js | 2 + app/angular/logic/logic.html | 334 ++++++++++++++++++++++++----------- app/angular/logic/logic.js | 10 ++ app/angular/view/view.html | 58 ++++++ app/angular/view/view.js | 32 ++++ app/sass/app.scss | 6 +- app/sass/buttons.scss | 4 + app/sass/form.scss | 4 + app/sass/sidebarPannel.scss | 7 +- 9 files changed, 355 insertions(+), 102 deletions(-) create mode 100644 app/angular/view/view.html create mode 100644 app/angular/view/view.js diff --git a/app/angular/index.js b/app/angular/index.js index 1c87a83c..f6486d73 100644 --- a/app/angular/index.js +++ b/app/angular/index.js @@ -18,6 +18,7 @@ import "../joint/joint.ui.stencil.css"; import "oclazyload"; import sidebarControlConceptual from "./conceptual/sidebarControl"; +import view from "./view/view"; import authService from "./service/authService"; import modelService from "./service/modelAPI"; import dropdownComponent from "./components/dropdown"; @@ -47,6 +48,7 @@ const app = angular.module("app", [ logicFactory, sidebarControlConceptual, dropdownIconComponent, + view, ]); app.config([ diff --git a/app/angular/logic/logic.html b/app/angular/logic/logic.html index 385e01f8..0e182c57 100644 --- a/app/angular/logic/logic.html +++ b/app/angular/logic/logic.html @@ -58,125 +58,250 @@

{{ 'Logical model of:' | translate }} {{$ctrl.model.nam
- + {{ 'Select an element to edit' | translate }}
-
- -
- - -
- -
-
- - +
+ -
- -
+ + +
+
+ + +
-
- - -
-
+ -
+
+ +
@@ -342,7 +478,7 @@

{{ 'Logical model of:' | translate }} {{$ctrl.model.nam

- + diff --git a/app/angular/logic/logic.js b/app/angular/logic/logic.js index 337de10e..0dc54c6c 100644 --- a/app/angular/logic/logic.js +++ b/app/angular/logic/logic.js @@ -45,6 +45,16 @@ const controller = function ( type: "success" } + ctrl.sections = { + tableProperties: true, + columns: false, + views: false, + } + + ctrl.toggleSection = (section) => { + ctrl.sections[section] = !ctrl.sections[section]; + } + ctrl.print = function () { window.print(); } diff --git a/app/angular/view/view.html b/app/angular/view/view.html new file mode 100644 index 00000000..95ebd0ad --- /dev/null +++ b/app/angular/view/view.html @@ -0,0 +1,58 @@ +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+ +
+ + +
+ +
+
\ No newline at end of file diff --git a/app/angular/view/view.js b/app/angular/view/view.js new file mode 100644 index 00000000..4ef3c700 --- /dev/null +++ b/app/angular/view/view.js @@ -0,0 +1,32 @@ +import angular from "angular"; +import template from "./view.html"; + +const app = angular.module("app.view", []); + +const Controller = function () { + const $ctrl = this; + + $ctrl.view = {}; + + $ctrl.$onChanges = (changes) => { + if (changes.table != null && changes.table.currentValue != null) { + $ctrl.view = changes.table.currentValue; + } + } + + $ctrl.toggleForm = () => { + $ctrl.formVisible = !$ctrl.formVisible; + }; + + $ctrl.save = () => { + console.log($ctrl.view); + } +}; + +export default app.component("view", { + template: template, + bindings: { + table: "<", + }, + controller: Controller, +}).name; diff --git a/app/sass/app.scss b/app/sass/app.scss index 4c0e19e1..802f41b9 100644 --- a/app/sass/app.scss +++ b/app/sass/app.scss @@ -12,4 +12,8 @@ @import 'sql.scss'; @import 'print.scss'; @import 'joint-custom.scss'; -@import 'sidebarPannel'; \ No newline at end of file +@import 'sidebarPannel'; + +:root { + accent-color: #3d9970; +} \ No newline at end of file diff --git a/app/sass/buttons.scss b/app/sass/buttons.scss index 701ecaee..e20ada3c 100644 --- a/app/sass/buttons.scss +++ b/app/sass/buttons.scss @@ -16,6 +16,10 @@ transition: all 0.25s ease; } +.br-button--full { + width: 100%; +} + .br-button:hover { color: #fff; background: #3d9970; diff --git a/app/sass/form.scss b/app/sass/form.scss index 429b067b..ee2c5857 100644 --- a/app/sass/form.scss +++ b/app/sass/form.scss @@ -175,4 +175,8 @@ input[type="submit"]:focus { textarea { resize: vertical; +} + +input[type="checkbox"] { + cursor: pointer; } \ No newline at end of file diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss index 0ef8d661..0d48f7c1 100644 --- a/app/sass/sidebarPannel.scss +++ b/app/sass/sidebarPannel.scss @@ -10,11 +10,12 @@ flex-direction: row; align-items: center; justify-content: space-between; - padding: 8px 12px; + padding: 12px; margin-bottom: 1px; color: #fff; background-color: #3d9970; cursor: pointer; + transition: ease .3s; } .panel-header:hover { @@ -101,4 +102,6 @@ padding-top: 12px;; } -.column-details-actions .br-button {width: 50%;} \ No newline at end of file +.column-details-actions .br-button {width: 50%;} + +.column-details .checkbox { margin: 4px 0; } \ No newline at end of file From 716235c3628e8e9c41e030c449a9526310d1d0d0 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Thu, 2 Dec 2021 19:47:51 -0300 Subject: [PATCH 04/54] Create ColumnForm component --- app/angular/logic/columnForm.html | 94 +++++++++++++++++++++++++++++++ app/angular/logic/columnForm.js | 36 ++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 app/angular/logic/columnForm.html create mode 100644 app/angular/logic/columnForm.js diff --git a/app/angular/logic/columnForm.html b/app/angular/logic/columnForm.html new file mode 100644 index 00000000..66e2b757 --- /dev/null +++ b/app/angular/logic/columnForm.html @@ -0,0 +1,94 @@ +
+
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + +
+ +
+ + +
+
\ No newline at end of file diff --git a/app/angular/logic/columnForm.js b/app/angular/logic/columnForm.js new file mode 100644 index 00000000..bc4bf31f --- /dev/null +++ b/app/angular/logic/columnForm.js @@ -0,0 +1,36 @@ +import angular from "angular"; +import template from "./columnForm.html"; + +const app = angular.module("app.columnForm", []); + +const Controller = function () { + const $ctrl = this; + + $ctrl.cancel = () => { + $ctrl.dismiss(); + }; + + $ctrl.selectType = function (selected) { + if (!$ctrl.column.PK && !$ctrl.column.FK) { + $ctrl.column.type = selected.type; + } else { + $ctrl.column.type = "INT"; + } + } + + $ctrl.selectTableOrigin = function (selected) { + $ctrl.column.tableOrigin.idName = selected.name; + } +}; + +export default app.component("columnForm", { + template: template, + bindings: { + save: "<", + dismiss: "&", + column: "<", + index: "<", + tableNames: "<" + }, + controller: Controller, +}).name; From d0fef5efd0ec912fe6f806779ce0da559144850c Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Thu, 2 Dec 2021 19:48:38 -0300 Subject: [PATCH 05/54] Add column form component to logic component --- app/angular/index.js | 2 - app/angular/logic/logic.html | 292 +---------------------------------- app/angular/logic/logic.js | 40 +---- app/joint/table.js | 6 +- 4 files changed, 16 insertions(+), 324 deletions(-) diff --git a/app/angular/index.js b/app/angular/index.js index f6486d73..1c87a83c 100644 --- a/app/angular/index.js +++ b/app/angular/index.js @@ -18,7 +18,6 @@ import "../joint/joint.ui.stencil.css"; import "oclazyload"; import sidebarControlConceptual from "./conceptual/sidebarControl"; -import view from "./view/view"; import authService from "./service/authService"; import modelService from "./service/modelAPI"; import dropdownComponent from "./components/dropdown"; @@ -48,7 +47,6 @@ const app = angular.module("app", [ logicFactory, sidebarControlConceptual, dropdownIconComponent, - view, ]); app.config([ diff --git a/app/angular/logic/logic.html b/app/angular/logic/logic.html index 0e182c57..d9064d47 100644 --- a/app/angular/logic/logic.html +++ b/app/angular/logic/logic.html @@ -43,7 +43,7 @@

{{ 'Logical model of:' | translate }} {{$ctrl.model.nam
  • @@ -98,199 +98,14 @@

    {{column.name}}

    PK -
    -
    - - -
    - -
    - - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - - -
    - -
    - - -
    -
    +
    -
    - - -
    - -
    - - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    - -
    - - - -
    - -
    - - -
    +
    - -
    @@ -299,8 +114,6 @@

    {{column.name}}

    - -

    aria-hidden="true" ng-click="$ctrl.deleteColumn(column, $index); $event.stopPropagation();" > - -
    -
    - - -
    - -
    - - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - - -
    - -
    - - -
    -
    - - + +
    diff --git a/app/sass/app.scss b/app/sass/app.scss index ce7161fa..f93beb8e 100644 --- a/app/sass/app.scss +++ b/app/sass/app.scss @@ -13,6 +13,7 @@ @import 'print.scss'; @import 'joint-custom.scss'; @import 'sidebarPannel'; +@import 'table-preview.scss'; :root { accent-color: #3d9970; diff --git a/app/sass/table-preview.scss b/app/sass/table-preview.scss new file mode 100644 index 00000000..0d95de2b --- /dev/null +++ b/app/sass/table-preview.scss @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// .table-preview +//////////////////////////////////////////////////////////////////////////////// +.table-preview { + border: 1px solid #bdbdbd; + border-radius: 2px 2px 0 0; +} + +.table-preview header { + padding: 12px 8px; + border-bottom: 1px solid #bdbdbd; + font-size: 1.3em; + background-color: rgba(#000, 0.1); // Fallback color +} + +.table-preview header h5 { + font-family: monospace; + font-weight: 500; + margin: 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// .table-preview-body +//////////////////////////////////////////////////////////////////////////////// +.table-preview-body .checkbox { + padding: 6px 8px; + margin: 0; +} + +.table-preview-body .checkbox:not(:last-child) { + border-bottom: 1px solid #bdbdbd; +} + +.table-preview-body .checkbox label { + font-size: 0.9em; +} From 3d31ed34773f54d7da48b7ae397a76c0845bfa42 Mon Sep 17 00:00:00 2001 From: "Idmar Ramos Jr. (Id)" Date: Sun, 5 Dec 2021 23:23:50 +0100 Subject: [PATCH 22/54] Add .query-expression-textarea - Set min-height for .query-expression-textarea --- app/angular/view/view.html | 2 +- app/sass/form.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/angular/view/view.html b/app/angular/view/view.html index f35c1504..0ad045d8 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -58,7 +58,7 @@
    TableNameGoesHere
    diff --git a/app/sass/form.scss b/app/sass/form.scss index a60c5df6..051f2fee 100644 --- a/app/sass/form.scss +++ b/app/sass/form.scss @@ -183,4 +183,8 @@ input[type="checkbox"] { .checkbox > label { word-break: break-all; +} + +.query-expression-textarea { + min-height: 125px; } \ No newline at end of file From 1cc674393fd421e2559fb07968b86e1754afb64a Mon Sep 17 00:00:00 2001 From: "Idmar Ramos Jr. (Id)" Date: Sun, 5 Dec 2021 23:31:30 +0100 Subject: [PATCH 23/54] .sidebar-block-action -> .card-item-actions - Follow semantics and use .card-item-actions as part of .card-item :) - Fix markup at views.html --- app/angular/logic/columnForm.html | 2 +- app/angular/view/view.html | 19 +++++++------------ app/sass/sidebarPannel.scss | 14 +++++++------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/angular/logic/columnForm.html b/app/angular/logic/columnForm.html index fc49b735..3795b5ea 100644 --- a/app/angular/logic/columnForm.html +++ b/app/angular/logic/columnForm.html @@ -92,7 +92,7 @@ -
    +
    diff --git a/app/angular/view/view.html b/app/angular/view/view.html index 0ad045d8..82884e63 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -64,18 +64,13 @@
    TableNameGoesHere
    - - +
    + + +
    +
    + +
    diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss index d0c3a22d..8339923b 100644 --- a/app/sass/sidebarPannel.scss +++ b/app/sass/sidebarPannel.scss @@ -92,29 +92,29 @@ .card-item .checkbox { margin: 4px 0; } //////////////////////////////////////////////////////////////////////////////// -// .card-item-action +// .card-item-actions //////////////////////////////////////////////////////////////////////////////// -.sidebar-block-actions { +.card-item-actions { align-items: center; border-top: 1px solid #ddd; padding-top: 12px; } -.sidebar-block-actions .actions-regular, -.sidebar-block-actions .actions-destructive { +.card-item-actions .actions-regular, +.card-item-actions .actions-destructive { box-sizing: border-box; } -.sidebar-block-actions .actions-destructive{ +.card-item-actions .actions-destructive{ padding-top: 12px; } -.sidebar-block-actions .actions-regular .br-button { +.card-item-actions .actions-regular .br-button { display: inline-block; width: calc(50% - 6px); margin: 0; } -.sidebar-block-actions .actions-regular .br-button:first-child { +.card-item-actions .actions-regular .br-button:first-child { margin-right: 8px; } \ No newline at end of file From 2d0225a6020b8313780bec7689f472ae119c43bb Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 5 Dec 2021 21:26:46 -0300 Subject: [PATCH 24/54] Create sidebarControlLogical component --- app/angular/logic/logic.html | 151 +------------------------- app/angular/logic/logic.js | 98 +---------------- app/angular/logic/sidebarControl.html | 91 ++++++++++++++++ app/angular/logic/sidebarControl.js | 124 +++++++++++++++++++++ 4 files changed, 219 insertions(+), 245 deletions(-) create mode 100644 app/angular/logic/sidebarControl.html create mode 100644 app/angular/logic/sidebarControl.js diff --git a/app/angular/logic/logic.html b/app/angular/logic/logic.html index 5f881a52..07de69f7 100644 --- a/app/angular/logic/logic.html +++ b/app/angular/logic/logic.html @@ -48,157 +48,10 @@

    {{ 'Logical model of:' | translate }} {{$ctrl.model.nam - - + + diff --git a/app/angular/logic/logic.js b/app/angular/logic/logic.js index 3ddb0c72..ef876b75 100644 --- a/app/angular/logic/logic.js +++ b/app/angular/logic/logic.js @@ -3,10 +3,10 @@ import template from "./logic.html"; import sqlGeneratorService from "../service/sqlGeneratorService"; import sqlGeneratorModal from "../components/sqlGeneratorModal"; import duplicateModelModal from "../components/duplicateModelModal"; -import Column from "../service/Column"; import preventExitServiceModule from "../service/preventExitService"; import view from "../view/view"; import columnForm from "./columnForm"; +import sidebarControlLogical from "./sidebarControl"; const controller = function ( $rootScope, @@ -47,20 +47,6 @@ const controller = function ( type: "success" } - ctrl.sections = { - tableProperties: true, - columns: false, - views: false, - } - - ctrl.toggleSection = (section) => { - ctrl.sections[section] = !ctrl.sections[section]; - } - - ctrl.changeVisible = function () { - ctrl.editionVisible = !ctrl.editionVisible; - } - ctrl.print = function () { window.print(); } @@ -74,12 +60,6 @@ const controller = function ( LogicService.buildWorkspace($stateParams.references.modelid, $rootScope.loggeduser, ctrl.stopLoading, $stateParams.references.conversionId); } - ctrl.closeAllColumns = function () { - for (var i = 0; i < ctrl.columns.length; i++) { - ctrl.columns[i].expanded = false; - } - } - ctrl.showFeedback = function (newMessage, show, type) { ctrl.feedback.message = $filter('translate')(newMessage); ctrl.feedback.showing = show; @@ -111,10 +91,6 @@ const controller = function ( $timeout(() => { ctrl.selectedLink = null; ctrl.selectedElement = element; - if (element != null) { - ctrl.selectedName = element.attributes.name; - ctrl.selectedType = element.attributes.type; - } }); }); @@ -169,76 +145,6 @@ const controller = function ( LogicService.editCardinalityB(card); } - ctrl.changeName = function () { - if (ctrl.selectedName != null && ctrl.selectedName != "") { - LogicService.editName(ctrl.selectedName); - } - } - - ctrl.deleteColumn = function (column, $index) { - LogicService.deleteColumn($index); - } - - ctrl.editionColumnMode = function (column) { - loadTables(); - ctrl.editColumnModel = JSON.parse(JSON.stringify(column)); - - ctrl.closeAllColumns(); - - column.expanded = true; - } - - ctrl.editColumn = function (editedColumn, $index) { - if (editedColumn.name == "") { - ctrl.showFeedback("The column name cannot be empty!", true, "error"); - return; - } - - LogicService.editColumn($index, editedColumn); - - ctrl.closeAllColumns(); - } - - ctrl.addColumn = function (column) { - if (column.name == "") { - ctrl.showFeedback("The column name cannot be empty!", true, "error"); - return; - } - - if (column.FK && column.tableOrigin.idName == "") { - ctrl.showFeedback("Select the foreign table source!", true, "error"); - return; - } else { - column.tableOrigin.idOrigin = ctrl.mapTables.get(column.tableOrigin.idName); - } - - LogicService.addColumn(column); - ctrl.addColumnModel = ctrl.newColumnObject(); - ctrl.addColumnVisible = false; - } - - const loadTables = () => { - ctrl.tableNames = []; - ctrl.mapTables = LogicService.getTablesMap(); - for (var key of ctrl.mapTables.keys()) { - ctrl.tableNames.push({"name": key, "type": key}); - } - } - - ctrl.showAddColumn = function (show) { - ctrl.addColumnVisible = show; - ctrl.addColumnModel = ctrl.newColumnObject(); - - loadTables(); - } - - ctrl.newColumnObject = function () { - return new Column(); - } - - ctrl.addColumnModel = ctrl.newColumnObject(); - ctrl.editColumnModel = ctrl.newColumnObject(); - ctrl.undoModel = function () { LogicService.undo(); } @@ -319,7 +225,7 @@ const controller = function ( }; export default angular - .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, view, columnForm]) + .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, view, columnForm, sidebarControlLogical]) .component("editorLogic", { template, controller, diff --git a/app/angular/logic/sidebarControl.html b/app/angular/logic/sidebarControl.html new file mode 100644 index 00000000..5e9cc2df --- /dev/null +++ b/app/angular/logic/sidebarControl.html @@ -0,0 +1,91 @@ + \ No newline at end of file diff --git a/app/angular/logic/sidebarControl.js b/app/angular/logic/sidebarControl.js new file mode 100644 index 00000000..c941351b --- /dev/null +++ b/app/angular/logic/sidebarControl.js @@ -0,0 +1,124 @@ +import angular from "angular"; +import template from "./sidebarControl.html"; +import Column from "../service/Column"; + +const app = angular.module("app.sidebarControl", []); + +const Controller = function (LogicService) { + const $ctrl = this; + + $ctrl.visible = true; + + $ctrl.sections = { + tableProperties: true, + columns: false, + views: false, + } + + $ctrl.toggleSection = (section) => { + $ctrl.sections[section] = !$ctrl.sections[section]; + } + + $ctrl.changeVisible = () => { + $ctrl.visible = !$ctrl.visible; + } + + $ctrl.changeName = () => { + if ($ctrl.selectedName) { + LogicService.editName($ctrl.selectedName); + } + } + + $ctrl.deleteColumn = ($index) => { + LogicService.deleteColumn($index); + } + + $ctrl.editionColumnMode = (column) => { + loadTables(); + $ctrl.editColumnModel = JSON.parse(JSON.stringify(column)); + $ctrl.closeAllColumns(); + column.expanded = true; + } + + $ctrl.editColumn = (editedColumn, $index) => { + if (editedColumn.name == "") { + $ctrl.showFeedback("The column name cannot be empty!", true, "error"); + return; + } + + LogicService.editColumn($index, editedColumn); + + $ctrl.closeAllColumns(); + } + + $ctrl.closeAllColumns = function () { + $ctrl.columns.forEach(column => { + column.expanded = false; + }); + } + + $ctrl.addColumn = function (column) { + if (column.name == "") { + $ctrl.showFeedback("The column name cannot be empty!", true, "error"); + return; + } + + if (column.FK && column.tableOrigin.idName == "") { + $ctrl.showFeedback("Select the foreign table source!", true, "error"); + return; + } else { + column.tableOrigin.idOrigin = $ctrl.mapTables.get(column.tableOrigin.idName); + } + + LogicService.addColumn(column); + $ctrl.addColumnModel = $ctrl.newColumnObject(); + $ctrl.addColumnVisible = false; + } + + $ctrl.showAddColumn = function (show) { + $ctrl.addColumnVisible = show; + $ctrl.addColumnModel = $ctrl.newColumnObject(); + loadTables(); + } + + const loadTables = () => { + $ctrl.tableNames = []; + $ctrl.mapTables = LogicService.getTablesMap(); + for (var key of $ctrl.mapTables.keys()) { + $ctrl.tableNames.push({ name: key, type: key }); + } + } + + $ctrl.newColumnObject = function () { + return new Column(); + } + + $ctrl.addColumnModel = $ctrl.newColumnObject(); + $ctrl.editColumnModel = $ctrl.newColumnObject(); + + const clearSidebar = () => { + $ctrl.selectedElement = null; + $ctrl.selectedName = null; + $ctrl.selectedType = null; + $ctrl.columns = null; + } + + $ctrl.$onChanges = (changes) => { + if (!changes.selected.currentValue) clearSidebar(); + if (changes.selected != null && changes.selected.currentValue != null) { + $ctrl.selectedElement = changes.selected.currentValue; + $ctrl.selectedName = changes.selected.currentValue.attributes.name; + $ctrl.selectedType = changes.selected.currentValue.attributes.type; + $ctrl.columns = changes.selected.currentValue.attributes.objects; + } + } +}; + +export default app.component("sidebarControlLogical", { + template: template, + bindings: { + selected: "<", + showFeedback: "<", + }, + controller: Controller, +}).name; From a6944516d29fd0ecef5151651b1b9a5bb4ec689c Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 5 Dec 2021 22:08:40 -0300 Subject: [PATCH 25/54] Add delete column function --- app/angular/logic/columnForm.html | 4 ++-- app/angular/logic/columnForm.js | 3 ++- app/angular/logic/sidebarControl.html | 22 +--------------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/angular/logic/columnForm.html b/app/angular/logic/columnForm.html index 3795b5ea..d457905b 100644 --- a/app/angular/logic/columnForm.html +++ b/app/angular/logic/columnForm.html @@ -97,8 +97,8 @@ -
    - +
    +

    \ No newline at end of file diff --git a/app/angular/logic/columnForm.js b/app/angular/logic/columnForm.js index bc4bf31f..c06b3699 100644 --- a/app/angular/logic/columnForm.js +++ b/app/angular/logic/columnForm.js @@ -30,7 +30,8 @@ export default app.component("columnForm", { dismiss: "&", column: "<", index: "<", - tableNames: "<" + tableNames: "<", + delete: "<" }, controller: Controller, }).name; diff --git a/app/angular/logic/sidebarControl.html b/app/angular/logic/sidebarControl.html index 0436e74e..3c784f27 100644 --- a/app/angular/logic/sidebarControl.html +++ b/app/angular/logic/sidebarControl.html @@ -47,7 +47,7 @@

    {{column.name}}

    PK - + @@ -57,26 +57,6 @@

    {{column.name}}

    -
    -
    - - -
    - -
    - - -
    -
    - + +
    +
    + +
    +
    \ No newline at end of file diff --git a/app/angular/logic/sidebarControl.js b/app/angular/logic/sidebarControl.js index 36e9cf52..5cfa0d44 100644 --- a/app/angular/logic/sidebarControl.js +++ b/app/angular/logic/sidebarControl.js @@ -8,6 +8,7 @@ const Controller = function (LogicService) { const $ctrl = this; $ctrl.visible = true; + $ctrl.views = []; $ctrl.sections = { tableProperties: true, @@ -40,6 +41,17 @@ const Controller = function (LogicService) { column.expanded = true; } + $ctrl.closeAllViews = () => { + $ctrl.views.forEach(view => { + view.expanded = false; + }); + } + + $ctrl.editView = (view) => { + $ctrl.closeAllViews(); + view.expanded = true; + } + $ctrl.editColumn = (editedColumn, $index) => { if (editedColumn.name == "") { $ctrl.showFeedback("The column name cannot be empty!", true, "error"); @@ -110,6 +122,9 @@ const Controller = function (LogicService) { $ctrl.selectedName = changes.selected.currentValue.attributes.name; $ctrl.selectedType = changes.selected.currentValue.attributes.type; $ctrl.columns = changes.selected.currentValue.attributes.objects; + if ($ctrl.selectedType === 'uml.Class') { + $ctrl.views = LogicService.loadViewsByTable(changes.selected.currentValue.id); + } } } }; diff --git a/app/angular/service/logicService.js b/app/angular/service/logicService.js index 76cdbf0d..a90ba7a2 100644 --- a/app/angular/service/logicService.js +++ b/app/angular/service/logicService.js @@ -395,6 +395,11 @@ const logicService = ($rootScope, ModelAPI, LogicFactory, LogicConversorService) $rootScope.$broadcast('element:update', ls.selectedElement); } + ls.save = function (view) { + ls.selectedElement.model.saveView(view); + $rootScope.$broadcast('element:update', ls.selectedElement); + } + ls.addColumn = function (column) { if (column.FK) { var myLink = new joint.shapes.erd.Line({ @@ -467,6 +472,33 @@ const logicService = ($rootScope, ModelAPI, LogicFactory, LogicConversorService) return map; } + const isTable = (element) => element.attributes.type === 'uml.Class'; + + const isView = (element) => element.attributes.type === 'uml.Abstract'; + + const filterViewsByTableId = (views, tableId) => views.some(({ id }) => id === tableId); + + ls.loadTables = () => { + const elements = ls.graph.getElements(); + return elements.filter(isTable).map(element => ({ + name: element.attributes.name, + columns: element.attributes.objects.map(object => ({ ...object, selected: false })), + id: element.id + })); + }; + + ls.filterTablesWithRelationship = (tableId) => { + const tables = ls.loadTables(); + return tables.filter(table => table.columns.some(({ tableOrigin }) => tableOrigin.idOrigin === tableId)); + } + + ls.loadViewsByTable = (tableId) => { + const elements = ls.graph.getElements(); + return elements.filter(isView) + .filter(({ attributes }) => filterViewsByTableId(attributes.objects, tableId)) + .map(({ attributes }) => ({ name: attributes.name, tables: attributes.objects })); + } + ls.buildTablesJson = function () { var map = new Map(); var elements = ls.graph.getElements(); diff --git a/app/angular/view/view.html b/app/angular/view/view.html index d172ce91..5d2cc439 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -2,22 +2,26 @@ - +
    - + +
    + +
    @@ -27,24 +31,25 @@ type="text" class="form-control" ng-model="$ctrl.view.name" + ng-change="$ctrl.changeName()" />
    -
    +
    -
    TableNameGoesHere
    +
    {{ table.name }}
    -
    +
    @@ -66,12 +71,12 @@
    TableNameGoesHere
    - +
    - +
    \ No newline at end of file diff --git a/app/angular/view/view.js b/app/angular/view/view.js index f2fa2bea..2379d90e 100644 --- a/app/angular/view/view.js +++ b/app/angular/view/view.js @@ -3,14 +3,27 @@ import template from "./view.html"; const app = angular.module("app.view", []); -const Controller = function () { +const Controller = function (LogicService) { const $ctrl = this; - $ctrl.view = {}; + $ctrl.$onInit = () => { + const allTables = LogicService.loadTables(); + $ctrl.tables = $ctrl.view.tables; + allTables.forEach(table => { + if ($ctrl.tables.some(({ name }) => table.name === name)) return; + $ctrl.tables.push(table); + }); + }; + + $ctrl.changeName = () => { + if ($ctrl.view.name) { + LogicService.editName($ctrl.view.name); + } + } $ctrl.$onChanges = (changes) => { - if (changes.table != null && changes.table.currentValue != null) { - $ctrl.view = changes.table.currentValue; + if (changes.view != null && changes.view.currentValue != null) { + $ctrl.view = changes.view.currentValue; } } @@ -18,16 +31,33 @@ const Controller = function () { $ctrl.formVisible = !$ctrl.formVisible; }; + $ctrl.cancel = () => { + $ctrl.dismiss(); + }; + $ctrl.save = () => { - console.log($ctrl.view); + let columns = []; + const filteredTables = $ctrl.tables.filter(({ selected }) => selected); + filteredTables.forEach(table => { + table.columns.forEach(column => { + if (column.selected) columns.push(column); + }) + }) + const view = { + ...$ctrl.view, + basedIn: filteredTables, + columns, + } + LogicService.save(view); } }; export default app.component("view", { template: template, bindings: { - table: "<", - tables: "<", + view: "<", + isEdit: "<", + dismiss: "<" }, controller: Controller, }).name; diff --git a/app/joint/table.js b/app/joint/table.js index ffd63242..85bad49b 100644 --- a/app/joint/table.js +++ b/app/joint/table.js @@ -182,34 +182,20 @@ uml.Abstract = joint.shapes.basic.Generic.extend({ return this.get('name'); }, - addAttribute: function (obj) { - if (obj.PK) { - obj.name = obj.name + ": PK"; - } - - if (obj.FK) { - obj.name = obj.name + ": FK"; - } - - this.get('attributes').push(obj.name); - this.get('objects').push(obj); + saveView: function (view) { + this.set('attributes', view.columns.map(column => column.name)); + this.set('objects', view.basedIn); this.updateRectangles(); this.trigger('uml-update'); - }, + }, - deleteColumn: function (index) { - this.get('attributes').splice(index, 1); - this.get('objects').splice(index, 1); + addAttributes: function (objects) { + objects.forEach(({ name }) => this.get('attributes').push(name)); + this.get('objects').push(objects); this.updateRectangles(); this.trigger('uml-update'); - }, + }, - editColumn: function (index, name, object) { - this.get('attributes')[index] = name; - this.get('objects')[index] = object; - this.updateRectangles(); - this.trigger('uml-update'); - }, updateRectangles: function () { diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss index 8339923b..7adab77c 100644 --- a/app/sass/sidebarPannel.scss +++ b/app/sass/sidebarPannel.scss @@ -65,7 +65,6 @@ flex-direction: row; align-items: center; justify-content: space-between; - ; } .card-item .table-title { @@ -117,4 +116,32 @@ .card-item-actions .actions-regular .br-button:first-child { margin-right: 8px; +} + +.views-list { + list-style: none; + padding: 0; +} + +.view-item { + padding: 12px 8px; + border: 1px solid #ddd; + border-radius: 3px; + margin-bottom: 8px; + cursor: pointer; +} + +.view-item header { + display: flex; + align-items: center; +} + +.view-item header i { + font-size: 16px; +} + +.view-item header h4 { + font-size: 14px; + font-weight: 400; + margin: 0 0 0 4px; } \ No newline at end of file diff --git a/app/sass/table-preview.scss b/app/sass/table-preview.scss index 0d95de2b..aa446fc6 100644 --- a/app/sass/table-preview.scss +++ b/app/sass/table-preview.scss @@ -4,6 +4,7 @@ .table-preview { border: 1px solid #bdbdbd; border-radius: 2px 2px 0 0; + margin-bottom: 12px; } .table-preview header { From dd5b936ba5021607f11186fcede02bf9c464ec85 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 9 Jan 2022 16:22:24 -0300 Subject: [PATCH 28/54] Add CheckConstraint component --- app/angular/components/dropdown.html | 4 +- app/angular/logic/checkConstraint.html | 41 +++++++++++ app/angular/logic/checkConstraint.js | 56 +++++++++++++++ app/angular/logic/columnForm.html | 98 ++++++++++++++------------ app/angular/logic/logic.js | 3 +- app/sass/sidebarPannel.scss | 13 ++++ 6 files changed, 165 insertions(+), 50 deletions(-) create mode 100644 app/angular/logic/checkConstraint.html create mode 100644 app/angular/logic/checkConstraint.js diff --git a/app/angular/components/dropdown.html b/app/angular/components/dropdown.html index 9b399acf..e1ff4900 100644 --- a/app/angular/components/dropdown.html +++ b/app/angular/components/dropdown.html @@ -1,8 +1,8 @@ diff --git a/app/angular/logic/checkConstraint.html b/app/angular/logic/checkConstraint.html new file mode 100644 index 00000000..6d1262f1 --- /dev/null +++ b/app/angular/logic/checkConstraint.html @@ -0,0 +1,41 @@ +
    +
    +
    + + + +
    + +
    + + + +
    +
    + +
    + + + +
    + + {{ $ctrl.isManual ? 'Show options to create constraint' : 'Create check constraint manually' | translate }} +
    \ No newline at end of file diff --git a/app/angular/logic/checkConstraint.js b/app/angular/logic/checkConstraint.js new file mode 100644 index 00000000..311f3b09 --- /dev/null +++ b/app/angular/logic/checkConstraint.js @@ -0,0 +1,56 @@ +import angular from "angular"; +import template from "./checkConstraint.html"; + +const app = angular.module("app.checkConstraint", []); + +const Controller = function () { + const $ctrl = this; + + $ctrl.isManual = true; + + $ctrl.toggleFormType = () => { + $ctrl.isManual = !$ctrl.isManual; + } + + $ctrl.checkConstraintOptions = { + NUMBER: [ + { name: 'Equal to', type: 'EQUAL_TO' }, + { name: 'Not equal to', type: 'NOT_EQUAL_TO' }, + { name: 'Greater than', type: 'GREATER_THAN' }, + { name: 'Less than', type: 'LESS_THAN' }, + { name: 'Between', type: 'BETWEEN' }, + { name: 'Greater than or equal to', type: 'GREATER_THAN_OR_EQUAL_TO' }, + { name: 'Less than or equal to', type: 'LESS_THAN_OR_EQUAL_TO' }, + ], + STRING: [ + { name: 'Is', type: 'IS' }, + { name: 'Is not', type: 'IS_NOT' }, + { name: 'Contains', type: 'CONTAINS' }, + { name: 'Does not contain', type: 'DOES_NOT_CONTAIN' }, + { name: 'Starts with', type: 'STARTS_WITH' }, + { name: 'Ends with', type: 'ENDS_WITH' }, + ] + }; + + $ctrl.selectCheckConstraint = (selected) => { + $ctrl.column.checkConstraint = { + type: selected.type, + name: selected.name, + }; + } + + $ctrl.$onChanges = (changes) => { + if (changes.column != null && changes.column.currentValue != null) { + $ctrl.column = changes.column.currentValue; + $ctrl.isManual = !$ctrl.column.checkConstraint; + } + } +} + +export default app.component("checkConstraint", { + template: template, + bindings: { + column: "<", + }, + controller: Controller, +}).name; \ No newline at end of file diff --git a/app/angular/logic/columnForm.html b/app/angular/logic/columnForm.html index d457905b..c13db195 100644 --- a/app/angular/logic/columnForm.html +++ b/app/angular/logic/columnForm.html @@ -29,57 +29,61 @@ />
    -
    - -
    + -
    - -
    +
    +
    + +
    -
    - -
    +
    + +
    -
    - -
    +
    + +
    -
    - +
    + +
    + +
    + +
    diff --git a/app/angular/logic/logic.js b/app/angular/logic/logic.js index 976bc5be..185d0958 100644 --- a/app/angular/logic/logic.js +++ b/app/angular/logic/logic.js @@ -8,6 +8,7 @@ import statusBar from "../components/statusBar"; import preventExitServiceModule from "../service/preventExitService"; import view from "../view/view"; import columnForm from "./columnForm"; +import checkConstraint from "./checkConstraint"; import sidebarControlLogical from "./sidebarControl"; const controller = function ( @@ -234,7 +235,7 @@ const controller = function ( }; export default angular - .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical]) + .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical, checkConstraint]) .component("editorLogic", { template, controller, diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss index 7adab77c..5337131e 100644 --- a/app/sass/sidebarPannel.scss +++ b/app/sass/sidebarPannel.scss @@ -144,4 +144,17 @@ font-size: 14px; font-weight: 400; margin: 0 0 0 4px; +} + +.check-constraint { + margin-bottom: 12px; +} + +.check-constraint .multiple-fields { + display: flex; + column-gap: 12px; +} + +.check-constraint .form-field { + margin-bottom: 12px; } \ No newline at end of file From f01fd1f3882e1e198ca10940ee6bd6635c0f6f0d Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 9 Jan 2022 16:22:34 -0300 Subject: [PATCH 29/54] Add check constraint translations --- app/i18n/languages/en.js | 19 ++++++++++++++++++- app/i18n/languages/pt_BR.js | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/i18n/languages/en.js b/app/i18n/languages/en.js index d17c28e3..ed3ec494 100644 --- a/app/i18n/languages/en.js +++ b/app/i18n/languages/en.js @@ -112,5 +112,22 @@ export default { 'Import': 'Import', 'Please select a .BRT file': 'Please select a .BRT file', 'Last save:': 'Last save:', - 'at': 'at' + 'at': 'at', + 'Equal to': 'Equal to', + 'Not equal to': 'Not equal to', + 'Greater than': 'Greater than', + 'Less than': 'Less than', + 'Between': 'Between', + 'Greater than or equal to': 'Greater than or equal to', + 'Less than or equal to': 'Less than or equal to', + 'Is': 'Is', + 'Is not': 'Is not', + 'Contains': 'Contains', + 'Does not contain': 'Does not contain', + 'Starts with': 'Starts with', + 'Ends with': 'Ends with', + 'Select a value': 'Select a value', + 'Type the expression check': 'Type the expression check', + 'Show options to create constraint': 'Show options to create constraint', + 'Create check constraint manually': 'Create check constraint manually', }; \ No newline at end of file diff --git a/app/i18n/languages/pt_BR.js b/app/i18n/languages/pt_BR.js index b4f7a859..dcdef537 100644 --- a/app/i18n/languages/pt_BR.js +++ b/app/i18n/languages/pt_BR.js @@ -113,4 +113,21 @@ export default { 'Please select a .BRT file': 'Por favor selecione um arquivo .BRT', 'Last save:': 'Salvo por último:', 'at': 'às', + 'Equal to': 'Igual', + 'Not equal to': 'Diferente', + 'Greater than': 'Maior que', + 'Less than': 'Menor que', + 'Between': 'Entre', + 'Greater than or equal to': 'Maior ou igual que', + 'Less than or equal to': 'Menor ou igual que', + 'Is': 'É', + 'Is not': 'Não é', + 'Contains': 'Contém', + 'Does not contain': 'Não contém', + 'Starts with': 'Começa com', + 'Ends with': 'Termina com', + 'Select a value': 'Selecione um valor', + 'Type the expression check': 'Digite a expressão check', + 'Show options to create constraint': 'Exibir opções para criar restrição', + 'Create check constraint manually': 'Criar restrição check manualmente', }; \ No newline at end of file From f0df83673bd5ce13c99abeaecf473fcad21891e9 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 16 Jan 2022 17:37:37 -0300 Subject: [PATCH 30/54] Creating sql comparasion dropdown component --- .../sqlComparasionDropdown/index.js | 41 +++++++++++++++++++ .../sqlComparasionDropdown/template.html | 5 +++ app/angular/logic/checkConstraint.html | 9 ++-- app/angular/logic/checkConstraint.js | 20 --------- 4 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 app/angular/components/sqlComparasionDropdown/index.js create mode 100644 app/angular/components/sqlComparasionDropdown/template.html diff --git a/app/angular/components/sqlComparasionDropdown/index.js b/app/angular/components/sqlComparasionDropdown/index.js new file mode 100644 index 00000000..9c2b4a89 --- /dev/null +++ b/app/angular/components/sqlComparasionDropdown/index.js @@ -0,0 +1,41 @@ +import angular from "angular"; +import template from "./template.html"; + +const Controller = function () { + const $ctrl = this; + + $ctrl.select = selected => { + $ctrl.selected = selected; + $ctrl.onSelect({ selected }); + } + + $ctrl.checkConstraintOptions = { + NUMBER: [ + { name: 'Equal to', type: 'EQUAL_TO' }, + { name: 'Not equal to', type: 'NOT_EQUAL_TO' }, + { name: 'Greater than', type: 'GREATER_THAN' }, + { name: 'Less than', type: 'LESS_THAN' }, + { name: 'Between', type: 'BETWEEN' }, + { name: 'Greater than or equal to', type: 'GREATER_THAN_OR_EQUAL_TO' }, + { name: 'Less than or equal to', type: 'LESS_THAN_OR_EQUAL_TO' }, + ], + STRING: [ + { name: 'Is', type: 'IS' }, + { name: 'Is not', type: 'IS_NOT' }, + { name: 'Contains', type: 'CONTAINS' }, + { name: 'Does not contain', type: 'DOES_NOT_CONTAIN' }, + { name: 'Starts with', type: 'STARTS_WITH' }, + { name: 'Ends with', type: 'ENDS_WITH' }, + ] + }; +}; + +export default angular.module("app.sqlComparasionDropdown", []).component("sqlComparasionDropdown", { + template, + controller: Controller, + bindings: { + type: "<", + selected: "<", + onSelect: "&" + }, +}).name; diff --git a/app/angular/components/sqlComparasionDropdown/template.html b/app/angular/components/sqlComparasionDropdown/template.html new file mode 100644 index 00000000..de1324ac --- /dev/null +++ b/app/angular/components/sqlComparasionDropdown/template.html @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/app/angular/logic/checkConstraint.html b/app/angular/logic/checkConstraint.html index 6d1262f1..56656f99 100644 --- a/app/angular/logic/checkConstraint.html +++ b/app/angular/logic/checkConstraint.html @@ -2,11 +2,12 @@
    - - + type="$ctrl.column.type"> +
    diff --git a/app/angular/logic/checkConstraint.js b/app/angular/logic/checkConstraint.js index 311f3b09..27ab21f2 100644 --- a/app/angular/logic/checkConstraint.js +++ b/app/angular/logic/checkConstraint.js @@ -12,26 +12,6 @@ const Controller = function () { $ctrl.isManual = !$ctrl.isManual; } - $ctrl.checkConstraintOptions = { - NUMBER: [ - { name: 'Equal to', type: 'EQUAL_TO' }, - { name: 'Not equal to', type: 'NOT_EQUAL_TO' }, - { name: 'Greater than', type: 'GREATER_THAN' }, - { name: 'Less than', type: 'LESS_THAN' }, - { name: 'Between', type: 'BETWEEN' }, - { name: 'Greater than or equal to', type: 'GREATER_THAN_OR_EQUAL_TO' }, - { name: 'Less than or equal to', type: 'LESS_THAN_OR_EQUAL_TO' }, - ], - STRING: [ - { name: 'Is', type: 'IS' }, - { name: 'Is not', type: 'IS_NOT' }, - { name: 'Contains', type: 'CONTAINS' }, - { name: 'Does not contain', type: 'DOES_NOT_CONTAIN' }, - { name: 'Starts with', type: 'STARTS_WITH' }, - { name: 'Ends with', type: 'ENDS_WITH' }, - ] - }; - $ctrl.selectCheckConstraint = (selected) => { $ctrl.column.checkConstraint = { type: selected.type, From c47c7213c24c701773bcb38971d7c736b156d6c2 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 16 Jan 2022 20:49:16 -0300 Subject: [PATCH 31/54] Add translations --- app/i18n/languages/en.js | 5 +++++ app/i18n/languages/pt_BR.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/i18n/languages/en.js b/app/i18n/languages/en.js index ed3ec494..44740811 100644 --- a/app/i18n/languages/en.js +++ b/app/i18n/languages/en.js @@ -130,4 +130,9 @@ export default { 'Type the expression check': 'Type the expression check', 'Show options to create constraint': 'Show options to create constraint', 'Create check constraint manually': 'Create check constraint manually', + 'Add condition': 'Add condition', + 'Create query expression': 'Create query expression', + 'Show options to create query': 'Show options to create query', + 'Add conditions to create query expression that will be used in the where clause when creating the view.': 'Add conditions to create query expression that will be used in the where clause when creating the view.', + 'and': 'and', }; \ No newline at end of file diff --git a/app/i18n/languages/pt_BR.js b/app/i18n/languages/pt_BR.js index dcdef537..0a4bf19e 100644 --- a/app/i18n/languages/pt_BR.js +++ b/app/i18n/languages/pt_BR.js @@ -130,4 +130,9 @@ export default { 'Type the expression check': 'Digite a expressão check', 'Show options to create constraint': 'Exibir opções para criar restrição', 'Create check constraint manually': 'Criar restrição check manualmente', + 'Add condition': 'Adicionar condição', + 'Create query expression': 'Criar expressão de consulta', + 'Show options to create query': 'Exibir opções para criar consulta', + 'Add conditions to create query expression that will be used in the where clause when creating the view.': 'Adicione condições para criar expressão de consulta que será utilizada na cláusula where na criação da view.', + 'and': 'e', }; \ No newline at end of file From 8d5e3dafbea9e0054c5bda021b32c82723d4d447 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 16 Jan 2022 20:50:12 -0300 Subject: [PATCH 32/54] Create query expression modal component --- .../components/queryExpressionModal/index.js | 98 +++++++++++++++++++ .../queryExpressionModal/styles.scss | 30 ++++++ .../queryExpressionModal/template.html | 60 ++++++++++++ app/angular/logic/logic.js | 4 +- app/angular/view/view.html | 2 + app/angular/view/view.js | 18 +++- 6 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 app/angular/components/queryExpressionModal/index.js create mode 100644 app/angular/components/queryExpressionModal/styles.scss create mode 100644 app/angular/components/queryExpressionModal/template.html diff --git a/app/angular/components/queryExpressionModal/index.js b/app/angular/components/queryExpressionModal/index.js new file mode 100644 index 00000000..e5f0e8b4 --- /dev/null +++ b/app/angular/components/queryExpressionModal/index.js @@ -0,0 +1,98 @@ +import angular from "angular"; +import template from "./template.html"; +import "./styles.scss"; + +const app = angular.module("app.queryExpressionModalController", []); + +const Controller = function ($filter) { + const $ctrl = this; + $ctrl.submitted = false; + $ctrl.conditions = []; + $ctrl.tableColumns = []; + + const defaultCondition = { + columnName: null, + columnType: null, + type: null, + comparativeValue: null, + submitted: false, + }; + + $ctrl.createLabel = condition => { + return `${condition.columnName} ${$filter('translate')(condition.name)} ${condition.comparativeValue} ${condition.comparativeValue2 ? `${$filter('translate')('and')} ${condition.comparativeValue2}` : '' }`; + } + + $ctrl.selectComparasion = (selected, index) => { + const selectedCondition = $ctrl.conditions[index]; + $ctrl.conditions[index] = { + ...selectedCondition, + name: selected.name, + type: selected.type, + }; + }; + + $ctrl.removeCondition = (index) => { + $ctrl.conditions.splice(index, 1); + } + + $ctrl.saveCondition = (index) => { + const selectedCondition = $ctrl.conditions[index]; + $ctrl.conditions[index] = { + ...selectedCondition, + submitted: true, + }; + } + + $ctrl.selectColumn = (selected, index) => { + const selectedCondition = $ctrl.conditions[index]; + $ctrl.conditions[index] = { + ...selectedCondition, + columnName: selected.name, + columnType: selected.type + }; + } + + $ctrl.addCondition = () => { + $ctrl.conditions.push(defaultCondition); + }; + + $ctrl.$onInit = () => { + $ctrl.tables.forEach(table => { + table.columns.forEach(column => { + $ctrl.tableColumns.push({ + name: `${table.name}.${column.name}`, + type: column.type, + }); + }); + }); + }; + + $ctrl.$onChanges = (changes) => { + if (changes.queryConditions != null && changes.queryConditions.currentValue != null) { + $ctrl.conditions = changes.queryConditions.currentValue || []; + } + } + + $ctrl.save = function () { + $ctrl.close({ + result: $ctrl.conditions.filter(condition => condition.submitted), + }); + }; + + $ctrl.cancel = function () { + $ctrl.dismiss({ + reason: "cancel", + }); + }; +}; + +export default app.component("queryExpressionModal", { + template, + bindings: { + close: "&", + dismiss: "&", + tables: "<", + queryConditions: '<' + }, + controller: Controller, +}).name; \ No newline at end of file diff --git a/app/angular/components/queryExpressionModal/styles.scss b/app/angular/components/queryExpressionModal/styles.scss new file mode 100644 index 00000000..7174bf4e --- /dev/null +++ b/app/angular/components/queryExpressionModal/styles.scss @@ -0,0 +1,30 @@ +.query-expression-modal { + .labels-wrapper { + margin-bottom: 12px; + display: flex; + flex-wrap: wrap; + column-gap: 8px; + + .condition-label { + padding: 6px; + background: #3d9970; + color: white; + border-radius: 4px; + + i { + margin-left: 8px; + cursor: pointer; + } + } + } + .form-content { + display: flex; + align-items: center; + column-gap: 8px; + margin-bottom: 12px; + + button { + min-width: 180px; + } + } +} \ No newline at end of file diff --git a/app/angular/components/queryExpressionModal/template.html b/app/angular/components/queryExpressionModal/template.html new file mode 100644 index 00000000..cbce6d64 --- /dev/null +++ b/app/angular/components/queryExpressionModal/template.html @@ -0,0 +1,60 @@ + + + + + \ No newline at end of file diff --git a/app/angular/logic/logic.js b/app/angular/logic/logic.js index 185d0958..ad26645f 100644 --- a/app/angular/logic/logic.js +++ b/app/angular/logic/logic.js @@ -3,6 +3,8 @@ import template from "./logic.html"; import sqlGeneratorService from "../service/sqlGeneratorService"; import sqlGeneratorModal from "../components/sqlGeneratorModal"; import duplicateModelModal from "../components/duplicateModelModal"; +import queryExpressionModal from "../components/queryExpressionModal"; +import sqlComparasionDropdown from "../components/sqlComparasionDropdown"; import bugReportButton from "../components/bugReportButton"; import statusBar from "../components/statusBar"; import preventExitServiceModule from "../service/preventExitService"; @@ -235,7 +237,7 @@ const controller = function ( }; export default angular - .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical, checkConstraint]) + .module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical, checkConstraint, queryExpressionModal, sqlComparasionDropdown]) .component("editorLogic", { template, controller, diff --git a/app/angular/view/view.html b/app/angular/view/view.html index 5d2cc439..e54e20a3 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -68,6 +68,8 @@
    {{ table.name }}
    >
    + {{ 'Show options to create query' | translate }} +
    diff --git a/app/angular/view/view.js b/app/angular/view/view.js index 2379d90e..37151487 100644 --- a/app/angular/view/view.js +++ b/app/angular/view/view.js @@ -3,7 +3,7 @@ import template from "./view.html"; const app = angular.module("app.view", []); -const Controller = function (LogicService) { +const Controller = function (LogicService, $uibModal) { const $ctrl = this; $ctrl.$onInit = () => { @@ -15,6 +15,22 @@ const Controller = function (LogicService) { }); }; + $ctrl.queryExpressionModal = () => { + const modalInstance = $uibModal.open({ + animation: true, + template: '', + controller: function () { + const ctrl = this; + ctrl.tables = $ctrl.tables.filter(({ selected }) => selected); + ctrl.queryConditions = $ctrl.view.queryConditions; + }, + controllerAs: '$ctrl', + }); + modalInstance.result.then((conditions) => { + $ctrl.view.queryConditions = conditions; + }); + }; + $ctrl.changeName = () => { if ($ctrl.view.name) { LogicService.editName($ctrl.view.name); From f6202e5b27681d0aed9bffc02642c2de3e872fc2 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 6 Feb 2022 16:40:49 -0300 Subject: [PATCH 33/54] Add translations --- app/angular/login/login.html | 4 ++-- app/angular/service/logicFactory.js | 8 ++++---- app/angular/view/view.html | 4 ++-- app/i18n/languages/en.js | 9 +++++++++ app/i18n/languages/pt_BR.js | 9 +++++++++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/angular/login/login.html b/app/angular/login/login.html index 47451a61..2d071623 100644 --- a/app/angular/login/login.html +++ b/app/angular/login/login.html @@ -59,8 +59,8 @@

    {{'Language' | translate}}

    diff --git a/app/angular/service/logicFactory.js b/app/angular/service/logicFactory.js index ece09952..86a4873e 100644 --- a/app/angular/service/logicFactory.js +++ b/app/angular/service/logicFactory.js @@ -3,14 +3,14 @@ import angular from "angular"; import * as joint from "jointjs/dist/joint"; import "jointjs/dist/joint.min.css"; -const logicFactory = () => { +const logicFactory = ($filter) => { var logic = joint.shapes.uml; const _createTable = function () { var table = new logic.Class({ position: { x: 12, y: 15 }, size: { width: 100, height: 100 }, - name: 'Tabela', + name: $filter('translate')('Table'), attributes: [], attrs: { '.uml-class-name-rect': { @@ -42,11 +42,11 @@ const logicFactory = () => { var table = new logic.Abstract({ position: { x: 12, y: 155 }, size: { width: 100, height: 100 }, - name: 'View', + name: $filter('translate')('View'), attributes: [], attrs: { '.uml-class-name-rect': { - fill: 'red', + fill: 'lightgray', stroke: '#000', 'stroke-width': 0.5, }, diff --git a/app/angular/view/view.html b/app/angular/view/view.html index e54e20a3..f5a16b2e 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -64,11 +64,11 @@
    {{ table.name }}
    id="view-query" type="text" class="form-control query-expression-textarea" - ng-model="$ctrl.view.query" + ng-model="$ctrl.view.queryConditions.text" > - {{ 'Show options to create query' | translate }} + {{ $ctrl.view.queryConditions.values ? 'Edit options to create query' : 'Show options to create query' | translate }}
    diff --git a/app/i18n/languages/en.js b/app/i18n/languages/en.js index 44740811..9bdcc509 100644 --- a/app/i18n/languages/en.js +++ b/app/i18n/languages/en.js @@ -133,6 +133,15 @@ export default { 'Add condition': 'Add condition', 'Create query expression': 'Create query expression', 'Show options to create query': 'Show options to create query', + 'Edit options to create query': 'Edit options to create query', 'Add conditions to create query expression that will be used in the where clause when creating the view.': 'Add conditions to create query expression that will be used in the where clause when creating the view.', 'and': 'and', + 'Add new column': 'Add new column', + 'Table': 'Table', + 'View': 'View', + 'Confirm': 'Confirm', + 'Portuguese (Brazil)': 'Portuguese (Brazil)', + 'English': 'English', + 'AND': 'AND', + 'OR': 'OR' }; \ No newline at end of file diff --git a/app/i18n/languages/pt_BR.js b/app/i18n/languages/pt_BR.js index 0a4bf19e..fbbe6304 100644 --- a/app/i18n/languages/pt_BR.js +++ b/app/i18n/languages/pt_BR.js @@ -133,6 +133,15 @@ export default { 'Add condition': 'Adicionar condição', 'Create query expression': 'Criar expressão de consulta', 'Show options to create query': 'Exibir opções para criar consulta', + 'Edit options to create query': 'Editar opções para criar consulta', 'Add conditions to create query expression that will be used in the where clause when creating the view.': 'Adicione condições para criar expressão de consulta que será utilizada na cláusula where na criação da view.', 'and': 'e', + 'Add new column': 'Adicionar coluna', + 'Table': 'Tabela', + 'View': 'Visão', + 'Confirm': 'Confirmar', + 'Portuguese (Brazil)': 'Português (Brasil)', + 'English': 'Inglês', + 'AND': 'E', + 'OR': 'OU' }; \ No newline at end of file From 66526f0b45c46f032c3a9e06524393a6be142d6a Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 6 Feb 2022 16:46:23 -0300 Subject: [PATCH 34/54] View - query expression --- .../components/queryExpressionModal/index.js | 13 ++++++++++-- .../queryExpressionModal/styles.scss | 5 +++-- .../queryExpressionModal/template.html | 13 ++++++++---- app/angular/logic/sidebarControl.html | 8 +++---- app/angular/logic/sidebarControl.js | 1 + app/angular/service/logicService.js | 2 +- app/angular/service/queryExpressionService.js | 15 +++++++++++++ app/angular/view/view.js | 21 ++++++++++++++----- app/joint/table.js | 3 ++- app/sass/form.scss | 2 +- 10 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 app/angular/service/queryExpressionService.js diff --git a/app/angular/components/queryExpressionModal/index.js b/app/angular/components/queryExpressionModal/index.js index e5f0e8b4..f998c35d 100644 --- a/app/angular/components/queryExpressionModal/index.js +++ b/app/angular/components/queryExpressionModal/index.js @@ -16,10 +16,19 @@ const Controller = function ($filter) { type: null, comparativeValue: null, submitted: false, + logicalOperator: 'AND', }; $ctrl.createLabel = condition => { - return `${condition.columnName} ${$filter('translate')(condition.name)} ${condition.comparativeValue} ${condition.comparativeValue2 ? `${$filter('translate')('and')} ${condition.comparativeValue2}` : '' }`; + return `${condition.columnName} ${$filter('translate')(condition.name).toLowerCase()} ${condition.comparativeValue} ${condition.comparativeValue2 ? `${$filter('translate')('and')} ${condition.comparativeValue2}` : '' }`; + } + + $ctrl.changeOperator = (index) => { + const selectedCondition = $ctrl.conditions[index]; + $ctrl.conditions[index] = { + ...selectedCondition, + logicalOperator: selectedCondition.logicalOperator === 'AND' ? 'OR' : 'AND', + }; } $ctrl.selectComparasion = (selected, index) => { @@ -69,7 +78,7 @@ const Controller = function ($filter) { $ctrl.$onChanges = (changes) => { if (changes.queryConditions != null && changes.queryConditions.currentValue != null) { - $ctrl.conditions = changes.queryConditions.currentValue || []; + $ctrl.conditions = changes.queryConditions.currentValue.values || []; } } diff --git a/app/angular/components/queryExpressionModal/styles.scss b/app/angular/components/queryExpressionModal/styles.scss index 7174bf4e..2967cb7a 100644 --- a/app/angular/components/queryExpressionModal/styles.scss +++ b/app/angular/components/queryExpressionModal/styles.scss @@ -3,16 +3,17 @@ margin-bottom: 12px; display: flex; flex-wrap: wrap; - column-gap: 8px; + row-gap: 18px; .condition-label { padding: 6px; background: #3d9970; color: white; border-radius: 4px; + margin-right: 8px; i { - margin-left: 8px; + margin-left: 4px; cursor: pointer; } } diff --git a/app/angular/components/queryExpressionModal/template.html b/app/angular/components/queryExpressionModal/template.html index cbce6d64..efd68696 100644 --- a/app/angular/components/queryExpressionModal/template.html +++ b/app/angular/components/queryExpressionModal/template.html @@ -6,12 +6,17 @@

    {{ 'Add conditions to create query expression that will be used in the where clause when creating the view.' | translate }}

    -
    + {{ $ctrl.createLabel(condition) }} -
    + + + {{ condition.logicalOperator | translate }} + + +
    @@ -45,7 +50,7 @@ /> - +
    @@ -56,5 +61,5 @@ \ No newline at end of file diff --git a/app/angular/logic/sidebarControl.html b/app/angular/logic/sidebarControl.html index 94cdf3a6..aa6c5857 100644 --- a/app/angular/logic/sidebarControl.html +++ b/app/angular/logic/sidebarControl.html @@ -65,13 +65,13 @@

    {{ 'Views' | translate }}

      -
    • -
      +
    • +

      {{view.name}}

      - +
    @@ -80,7 +80,7 @@

    {{view.name}}

    - +
    \ No newline at end of file diff --git a/app/angular/logic/sidebarControl.js b/app/angular/logic/sidebarControl.js index 5cfa0d44..03191a4d 100644 --- a/app/angular/logic/sidebarControl.js +++ b/app/angular/logic/sidebarControl.js @@ -122,6 +122,7 @@ const Controller = function (LogicService) { $ctrl.selectedName = changes.selected.currentValue.attributes.name; $ctrl.selectedType = changes.selected.currentValue.attributes.type; $ctrl.columns = changes.selected.currentValue.attributes.objects; + $ctrl.queryConditions = changes.selected.currentValue.attributes.queryConditions; if ($ctrl.selectedType === 'uml.Class') { $ctrl.views = LogicService.loadViewsByTable(changes.selected.currentValue.id); } diff --git a/app/angular/service/logicService.js b/app/angular/service/logicService.js index 8ec25f68..e23c1d84 100644 --- a/app/angular/service/logicService.js +++ b/app/angular/service/logicService.js @@ -495,7 +495,7 @@ const logicService = ($rootScope, ModelAPI, LogicFactory, LogicConversorService) const elements = ls.graph.getElements(); return elements.filter(isView) .filter(({ attributes }) => filterViewsByTableId(attributes.objects, tableId)) - .map(({ attributes }) => ({ name: attributes.name, tables: attributes.objects })); + .map(({ attributes }) => ({ name: attributes.name, tables: attributes.objects, queryConditions: attributes.queryConditions })); } ls.buildTablesJson = function () { diff --git a/app/angular/service/queryExpressionService.js b/app/angular/service/queryExpressionService.js new file mode 100644 index 00000000..04100af6 --- /dev/null +++ b/app/angular/service/queryExpressionService.js @@ -0,0 +1,15 @@ +export const comparasionOperators = { + EQUAL_TO: (value) => `= ${value}`, + NOT_EQUAL_TO: (value) => `<> ${value}`, + GREATER_THAN: (value) => `> ${value}`, + LESS_THAN: (value) => `< ${value}`, + BETWEEN: (value, otherValue) => `BETWEEN ${value} AND ${otherValue}`, + GREATER_THAN_OR_EQUAL_TO: (value) => `>= ${value}`, + LESS_THAN_OR_EQUAL_TO: (value) => `<= ${value}`, + IS: (value) => `= ${value}`, + IS_NOT: (value) => `<> ${value}`, + CONTAINS: (value) => `LIKE '%${value}%'`, + DOES_NOT_CONTAIN: (value) => `NOT LIKE '%${value}%'`, + STARTS_WITH: (value) => `LIKE '${value}%'`, + ENDS_WITH: (value) => `LIKE '%${value}'`, +} \ No newline at end of file diff --git a/app/angular/view/view.js b/app/angular/view/view.js index 37151487..bc84d6d2 100644 --- a/app/angular/view/view.js +++ b/app/angular/view/view.js @@ -1,4 +1,5 @@ import angular from "angular"; +import { comparasionOperators } from "../service/queryExpressionService"; import template from "./view.html"; const app = angular.module("app.view", []); @@ -6,19 +7,24 @@ const app = angular.module("app.view", []); const Controller = function (LogicService, $uibModal) { const $ctrl = this; - $ctrl.$onInit = () => { + const updateViewInfo = (view) => { const allTables = LogicService.loadTables(); - $ctrl.tables = $ctrl.view.tables; + $ctrl.tables = view.tables; + $ctrl.queryConditions = view.queryConditions; allTables.forEach(table => { if ($ctrl.tables.some(({ name }) => table.name === name)) return; $ctrl.tables.push(table); }); + } + + $ctrl.$onInit = () => { + updateViewInfo($ctrl.view); }; $ctrl.queryExpressionModal = () => { const modalInstance = $uibModal.open({ animation: true, - template: '', + template: '', controller: function () { const ctrl = this; ctrl.tables = $ctrl.tables.filter(({ selected }) => selected); @@ -27,7 +33,11 @@ const Controller = function (LogicService, $uibModal) { controllerAs: '$ctrl', }); modalInstance.result.then((conditions) => { - $ctrl.view.queryConditions = conditions; + $ctrl.view.queryConditions = { + values: conditions, + text: `${conditions.map(({ columnName, type, comparativeValue, comparativeValue2, logicalOperator }, index) => + `${columnName} ${comparasionOperators[type](comparativeValue, comparativeValue2)} ${conditions.length - 1 === index ? '' : logicalOperator}`).join(" ")}` + } }); }; @@ -39,7 +49,7 @@ const Controller = function (LogicService, $uibModal) { $ctrl.$onChanges = (changes) => { if (changes.view != null && changes.view.currentValue != null) { - $ctrl.view = changes.view.currentValue; + updateViewInfo({ ...changes.view.currentValue }); } } @@ -65,6 +75,7 @@ const Controller = function (LogicService, $uibModal) { columns, } LogicService.save(view); + } }; diff --git a/app/joint/table.js b/app/joint/table.js index 85bad49b..fd6a98a3 100644 --- a/app/joint/table.js +++ b/app/joint/table.js @@ -141,7 +141,7 @@ uml.Abstract = joint.shapes.basic.Generic.extend({ attrs: { rect: { 'width': 200 }, - '.uml-class-name-rect': { 'stroke': 'black', 'stroke-width': 0.5, 'fill': 'red' }, + '.uml-class-name-rect': { 'stroke': 'black', 'stroke-width': 0.5, 'fill': 'lightgray' }, '.uml-class-attrs-rect': { 'stroke': 'black', 'stroke-width': 0.5, 'fill': '#fff' }, '.uml-class-methods-rect': { 'stroke': 'black', 'stroke-width': 0.5, 'fill': '#fff' }, @@ -185,6 +185,7 @@ uml.Abstract = joint.shapes.basic.Generic.extend({ saveView: function (view) { this.set('attributes', view.columns.map(column => column.name)); this.set('objects', view.basedIn); + this.set('queryConditions', view.queryConditions); this.updateRectangles(); this.trigger('uml-update'); }, diff --git a/app/sass/form.scss b/app/sass/form.scss index 051f2fee..2d3c546c 100644 --- a/app/sass/form.scss +++ b/app/sass/form.scss @@ -25,7 +25,7 @@ input[type="button"]:focus, input[type="submit"]:focus { outline: 0; box-shadow: 0 0 0 2px rgba(#fff, 1), - 0 0 0 8px rgba(#3d9970, 0.4); + 0 0 0 4px rgba(#3d9970, 0.4); } //////////////////////////////////////////////////////////////////////////////// From 4cc8683ae5b0b2fba72fb540e122748608c335ad Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Mon, 7 Feb 2022 18:58:35 -0300 Subject: [PATCH 35/54] Filter tables --- app/angular/service/logicService.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/angular/service/logicService.js b/app/angular/service/logicService.js index e23c1d84..76baaa45 100644 --- a/app/angular/service/logicService.js +++ b/app/angular/service/logicService.js @@ -501,13 +501,13 @@ const logicService = ($rootScope, ModelAPI, LogicFactory, LogicConversorService) ls.buildTablesJson = function () { var map = new Map(); var elements = ls.graph.getElements(); - for (var i = 0; i < elements.length; i++) { + elements.filter(isTable).forEach(element => { var obj = { - "name": elements[i].attributes.name, - "columns": elements[i].attributes.objects + name: element.attributes.name, + columns: element.attributes.objects } - map.set(elements[i].id, obj); - } + map.set(element.id, obj); + }); return map; } From e931053efe11dcf05da17bb0ecb54954ae67ecf8 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Mon, 7 Feb 2022 18:59:05 -0300 Subject: [PATCH 36/54] Clear sidebar --- app/angular/logic/columnForm.html | 2 +- app/angular/logic/sidebarControl.html | 2 +- app/angular/logic/sidebarControl.js | 4 ++-- app/angular/service/sqlGeneratorService.js | 6 +++--- app/sass/sidebarPannel.scss | 8 +++++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/angular/logic/columnForm.html b/app/angular/logic/columnForm.html index c13db195..f9c0609f 100644 --- a/app/angular/logic/columnForm.html +++ b/app/angular/logic/columnForm.html @@ -1,4 +1,4 @@ -
    +
    {{view.name}}
    - +
    \ No newline at end of file diff --git a/app/angular/logic/sidebarControl.js b/app/angular/logic/sidebarControl.js index 03191a4d..423c6eca 100644 --- a/app/angular/logic/sidebarControl.js +++ b/app/angular/logic/sidebarControl.js @@ -108,7 +108,7 @@ const Controller = function (LogicService) { $ctrl.addColumnModel = $ctrl.newColumnObject(); $ctrl.editColumnModel = $ctrl.newColumnObject(); - const clearSidebar = () => { + $ctrl.clearSidebar = () => { $ctrl.selectedElement = null; $ctrl.selectedName = null; $ctrl.selectedType = null; @@ -116,7 +116,7 @@ const Controller = function (LogicService) { } $ctrl.$onChanges = (changes) => { - if (!changes.selected.currentValue) clearSidebar(); + if (!changes.selected.currentValue) $ctrl.clearSidebar(); if (changes.selected != null && changes.selected.currentValue != null) { $ctrl.selectedElement = changes.selected.currentValue; $ctrl.selectedName = changes.selected.currentValue.attributes.name; diff --git a/app/angular/service/sqlGeneratorService.js b/app/angular/service/sqlGeneratorService.js index 0adc9b57..b7fe33ea 100644 --- a/app/angular/service/sqlGeneratorService.js +++ b/app/angular/service/sqlGeneratorService.js @@ -51,17 +51,17 @@ const sqlGeneratorService = () => { var alreadyCreated = createdMap.get(key); create += " " + cleanString(column.name) + " " + column.type; - + constraints.forEach(({ key, sqlValue }) => { if (column[key]) create += ` ${sqlValue}`; }); - if(column.defaultValue) { + if (column.defaultValue) { create += ` DEFAULT '${column.defaultValue}'` } create += ", " + " \n"; - if(column.FK){ + if (column.FK){ pending.set(key, table); } } diff --git a/app/sass/sidebarPannel.scss b/app/sass/sidebarPannel.scss index 5337131e..749662bf 100644 --- a/app/sass/sidebarPannel.scss +++ b/app/sass/sidebarPannel.scss @@ -54,17 +54,23 @@ // .card-item //////////////////////////////////////////////////////////////////////////////// .card-item { - padding: 12px 8px; border: 1px solid #ddd; border-radius: 3px; margin-bottom: 8px; } +.card-item .column-form, +.card-item.views { + padding: 12px 8px; +} + .card-item header { display: flex; flex-direction: row; align-items: center; justify-content: space-between; + padding: 12px 8px; + cursor: pointer; } .card-item .table-title { From 0734138ac149f10654f59e2f30b34867e4ee2088 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Tue, 8 Feb 2022 08:15:42 -0300 Subject: [PATCH 37/54] Add check constraint to sql generator --- app/angular/service/sqlGeneratorService.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/angular/service/sqlGeneratorService.js b/app/angular/service/sqlGeneratorService.js index b7fe33ea..5acc2947 100644 --- a/app/angular/service/sqlGeneratorService.js +++ b/app/angular/service/sqlGeneratorService.js @@ -1,10 +1,10 @@ import angular from "angular"; +import { comparasionOperators } from "./queryExpressionService"; const sqlGeneratorService = () => { const constraints = [ { key: 'PK', sqlValue: "PRIMARY KEY" }, { key: 'NOT_NULL', sqlValue: "NOT NULL" }, - { key: 'UNIQUE', sqlValue: "UNIQUE" }, { key: 'AUTO_INCREMENT', sqlValue: "AUTO_INCREMENT" }, ]; @@ -47,7 +47,10 @@ const sqlGeneratorService = () => { const createTable = function(key, table){ var create = "CREATE TABLE " + table.name + " \n"; create += "( \n"; - for (const column of table.columns) { + const hasCheckConstraint = table.columns.some(column => column.checkConstraint); + const hasUniqueConstraint = table.columns.some(column => column.UNIQUE); + let checkConstraint = ''; + table.columns.forEach((column, index) => { var alreadyCreated = createdMap.get(key); create += " " + cleanString(column.name) + " " + column.type; @@ -64,7 +67,18 @@ const sqlGeneratorService = () => { if (column.FK){ pending.set(key, table); } + }) + + if (hasCheckConstraint) { + checkConstraint = ` CHECK (${table.columns.filter(column => column.checkConstraint) + .map(({ name, checkConstraint }, index) => `${index === 0 ? '': ' AND '}${name} ${comparasionOperators[checkConstraint.type](checkConstraint.comparativeValue, checkConstraint.comparativeValue2)}`).join("")})${hasUniqueConstraint ? ',' : ''}` + create += checkConstraint + "\n"; } + + if (hasUniqueConstraint) { + create += ` UNIQUE (${table.columns.filter(column => column.UNIQUE).map(({ name }) => `${name}`)})` + "\n"; + } + create += "); \n\n" return create; } From 3306ceb8110ae8edcc97c7cfdd8d833c8e5ab285 Mon Sep 17 00:00:00 2001 From: Arthur Mota Date: Sun, 13 Feb 2022 17:13:14 -0300 Subject: [PATCH 38/54] Fix column/table id --- app/angular/view/view.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/angular/view/view.html b/app/angular/view/view.html index f5a16b2e..d6be9ea5 100644 --- a/app/angular/view/view.html +++ b/app/angular/view/view.html @@ -45,9 +45,9 @@
    {{ table.name }}
    -