Skip to content

Commit 84a8c04

Browse files
authored
Merge pull request #359 from brmodeloweb/release/v0.1.4
Release/v0.1.4
2 parents 8f2156d + face565 commit 84a8c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1713
-504
lines changed

app/angular/components/confirmationModal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ <h3 class="modal-title">{{$ctrl.title}}</h3>
77
</div>
88

99
<div class="modal-footer">
10-
<button class="br-button yellow" type="button" ng-click="$ctrl.cancel()">{{$ctrl.cancelLabel}}</button>
10+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{$ctrl.cancelLabel}}</button>
1111
<button class="br-button" type="button" ng-click="$ctrl.confirm()">{{$ctrl.confirmLabel}}</button>
1212
</div>

app/angular/components/createModelModal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ <h3 class="modal-title">{{ 'New model' | translate }}</h3>
3131
</div>
3232

3333
<div class="modal-footer">
34-
<button class="br-button yellow" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
34+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
3535
<button type="button" class="br-button" ng-click="$ctrl.save($ctrl.name)">{{ 'Save' | translate }}</button>
3636
</div>

app/angular/components/deleteModelModal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ <h3 class="modal-title">{{ 'Delete model' | translate }}</h3>
77
</div>
88

99
<div class="modal-footer">
10-
<button class="br-button yellow" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
10+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
1111
<button class="br-button" type="button" ng-click="$ctrl.delete()">{{ 'Delete' | translate }}</button>
1212
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div class="dropdown-tmp dropdown-tmp-btn" ng-class="{expanded: $ctrl.open}">
22
<div class="dropdown-tmp-trigger" ng-click="$ctrl.toggle(true)">
3-
<button class="btn ng-binding">{{$ctrl.selected.name}}</button>
3+
<button class="btn ng-binding" ng-disabled="$ctrl.disabled">{{ $ctrl.selected.name | translate }}</button>
44
</div>
55
<ul class="dropdown-tmp-list" style="min-width: 140px;">
6-
<li class="dropdown-tmp-item" ng-repeat="option in $ctrl.options" ng-click="$ctrl.select(option)"><span>{{option.name}}</span></li>
6+
<li class="dropdown-tmp-item" ng-repeat="option in $ctrl.options" ng-click="$ctrl.select(option)"><span>{{ option.name | translate }}</span></li>
77
</ul>
88
</div>

app/angular/components/dropdown.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ export default angular.module("app.dropdown", []).component("dropdown", {
3434
options: "<",
3535
selected: "<",
3636
onSelect: "&",
37+
disabled: '<'
3738
},
3839
}).name;

app/angular/components/duplicateModelModal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ <h3 class="modal-title">{{ 'Duplicate model' | translate }}</h3>
2323
</div>
2424

2525
<div class="modal-footer">
26-
<button class="br-button yellow" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
26+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
2727
<button class="br-button" type="button" ng-click="$ctrl.save($ctrl.name)">{{ 'Save' | translate }}</button>
2828
</div>
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import angular from "angular";
2+
import template from "./template.html";
3+
import "./styles.scss";
4+
5+
const app = angular.module("app.queryExpressionModalController", []);
6+
7+
const AND_OPERATOR = 'AND';
8+
const OR_OPERATOR = 'OR';
9+
10+
const Controller = function ($filter) {
11+
const $ctrl = this;
12+
$ctrl.submitted = false;
13+
$ctrl.conditions = [];
14+
$ctrl.joins = [];
15+
$ctrl.tableColumns = [];
16+
17+
const defaultJoin = {
18+
columnNameOrigin: null,
19+
columnNameTarget: null,
20+
}
21+
22+
const defaultCondition = {
23+
columnName: null,
24+
columnType: null,
25+
type: null,
26+
comparativeValue: null,
27+
submitted: false,
28+
logicalOperator: AND_OPERATOR,
29+
};
30+
31+
$ctrl.selectColumnJoin = (selected, attribute, index) => {
32+
const selectedJoin = $ctrl.joins[index];
33+
$ctrl.joins[index] = {
34+
...selectedJoin,
35+
[attribute]: selected.name,
36+
};
37+
}
38+
39+
$ctrl.saveJoin = (index) => {
40+
const selectedJoin = $ctrl.joins[index];
41+
$ctrl.joins[index] = {
42+
...selectedJoin,
43+
submitted: true,
44+
};
45+
}
46+
47+
$ctrl.removeJoin = (index) => {
48+
$ctrl.joins.splice(index, 1);
49+
}
50+
51+
$ctrl.createLabel = condition => {
52+
return `${condition.columnName} ${$filter('translate')(condition.name).toLowerCase()} ${condition.comparativeValue} ${condition.comparativeValue2 ? `${$filter('translate')('and')} ${condition.comparativeValue2}` : '' }`;
53+
}
54+
55+
$ctrl.changeOperator = (index) => {
56+
const selectedCondition = $ctrl.conditions[index];
57+
$ctrl.conditions[index] = {
58+
...selectedCondition,
59+
logicalOperator: selectedCondition.logicalOperator === AND_OPERATOR ? OR_OPERATOR : AND_OPERATOR,
60+
};
61+
}
62+
63+
$ctrl.selectComparasion = (selected, index) => {
64+
const selectedCondition = $ctrl.conditions[index];
65+
$ctrl.conditions[index] = {
66+
...selectedCondition,
67+
name: selected.name,
68+
type: selected.type,
69+
};
70+
};
71+
72+
$ctrl.removeCondition = (index) => {
73+
$ctrl.conditions.splice(index, 1);
74+
}
75+
76+
$ctrl.saveCondition = (index) => {
77+
const selectedCondition = $ctrl.conditions[index];
78+
$ctrl.conditions[index] = {
79+
...selectedCondition,
80+
submitted: true,
81+
};
82+
}
83+
84+
$ctrl.selectColumn = (selected, index) => {
85+
const selectedCondition = $ctrl.conditions[index];
86+
$ctrl.conditions[index] = {
87+
...selectedCondition,
88+
columnName: selected.name,
89+
columnType: selected.type
90+
};
91+
}
92+
93+
$ctrl.addCondition = () => {
94+
$ctrl.conditions.push(defaultCondition);
95+
};
96+
97+
$ctrl.addJoin = () => {
98+
$ctrl.joins.push(defaultJoin);
99+
}
100+
101+
$ctrl.$onInit = () => {
102+
$ctrl.showJoins = $ctrl.tables.length > 1;
103+
$ctrl.tables.forEach(table => {
104+
table.columns.forEach(column => {
105+
$ctrl.tableColumns.push({
106+
name: `${table.name}.${column.name}`,
107+
type: column.type,
108+
});
109+
});
110+
});
111+
};
112+
113+
$ctrl.$onChanges = (changes) => {
114+
if (changes.queryConditions != null && changes.queryConditions.currentValue != null) {
115+
$ctrl.conditions = changes.queryConditions.currentValue.values || [];
116+
$ctrl.joins = changes.queryConditions.currentValue.joins || [];
117+
}
118+
}
119+
120+
$ctrl.save = function () {
121+
$ctrl.close({
122+
result: {
123+
conditions: $ctrl.conditions.filter(condition => condition.submitted),
124+
joins: $ctrl.joins.filter(join => join.submitted),
125+
}
126+
});
127+
};
128+
129+
$ctrl.cancel = function () {
130+
$ctrl.dismiss({
131+
reason: "cancel",
132+
});
133+
};
134+
};
135+
136+
export default app.component("queryExpressionModal", {
137+
template,
138+
bindings: {
139+
close: "&",
140+
dismiss: "&",
141+
tables: "<",
142+
queryConditions: '<'
143+
},
144+
controller: Controller,
145+
}).name;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.query-expression-modal {
2+
.labels-wrapper {
3+
margin-bottom: 12px;
4+
display: flex;
5+
flex-wrap: wrap;
6+
row-gap: 18px;
7+
8+
.condition-label {
9+
padding: 6px;
10+
background: #3d9970;
11+
color: white;
12+
border-radius: 4px;
13+
margin-right: 8px;
14+
15+
i {
16+
margin-left: 4px;
17+
cursor: pointer;
18+
}
19+
}
20+
}
21+
.form-content {
22+
display: flex;
23+
align-items: center;
24+
column-gap: 8px;
25+
margin-bottom: 12px;
26+
27+
button {
28+
min-width: 180px;
29+
}
30+
31+
.dropdown-tmp-list {
32+
max-height: 400px;
33+
overflow: auto;
34+
}
35+
}
36+
.form-content-joins {
37+
dropdown {
38+
width: 100%;
39+
}
40+
}
41+
.modal-message {
42+
margin-top: 16px;
43+
}
44+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<div class="modal-header">
2+
<h3 class="modal-title">{{ 'Create query expression' | translate }}</h3>
3+
</div>
4+
5+
<div class="modal-body query-expression-modal">
6+
<div ng-if="$ctrl.showJoins">
7+
<p>{{ 'You have chosen multiple tables to create the View. It is necessary to select the attributes that will compose the JOIN clause.' | translate }}</p>
8+
9+
<div class="labels-wrapper">
10+
<span ng-repeat="join in $ctrl.joins track by $index">
11+
<span class="condition-label" ng-if="join.submitted">
12+
{{ join.columnNameOrigin + ' = ' + join.columnNameTarget }}
13+
<i title="{{ 'Delete' | translate }}" class="fa fa-close" ng-click="$ctrl.removeJoin($index)"></i>
14+
</span>
15+
</span>
16+
</div>
17+
18+
<div ng-repeat="join in $ctrl.joins track by $index">
19+
<div class="form-content form-content-joins" ng-if="!join.submitted">
20+
<dropdown
21+
on-select="$ctrl.selectColumnJoin(selected, 'columnNameOrigin', $index)"
22+
selected="{ name: join.columnNameOrigin || 'Select a value' }"
23+
options="$ctrl.tableColumns">
24+
</dropdown>
25+
26+
<dropdown
27+
on-select="$ctrl.selectColumnJoin(selected, 'columnNameTarget', $index)"
28+
selected="{ name: join.columnNameTarget || 'Select a value' }"
29+
options="$ctrl.tableColumns">
30+
</dropdown>
31+
32+
<a class="br-button" ng-if="join.columnNameOrigin && join.columnNameTarget" data-ng-click="$ctrl.saveJoin($index)">
33+
<i title="{{ 'Save' | translate }}" class="fa fa-check"></i>
34+
</a>
35+
</div>
36+
</div>
37+
38+
<button class="br-button" type="button" ng-click="$ctrl.addJoin()">{{ 'Add join' | translate }}</button>
39+
</div>
40+
41+
<p class="modal-message">{{ 'Add conditions to create query expression that will be used in the where clause when creating the view.' | translate }}</p>
42+
43+
<div class="labels-wrapper">
44+
<span ng-repeat="condition in $ctrl.conditions track by $index">
45+
<span class="condition-label" ng-if="condition.submitted">
46+
{{ $ctrl.createLabel(condition) }}
47+
<i title="{{ 'Delete' | translate }}" class="fa fa-close" ng-click="$ctrl.removeCondition($index)"></i>
48+
</span>
49+
50+
<span class="condition-label" ng-if="!$last && condition.submitted">
51+
{{ condition.logicalOperator | translate }}
52+
<i title="{{ 'Alterar operador lógico' | translate }}" class="fa fa-exchange" ng-click="$ctrl.changeOperator($index)"></i>
53+
</span>
54+
</span>
55+
</div>
56+
57+
<div ng-repeat="condition in $ctrl.conditions track by $index">
58+
<div class="form-content" ng-if="!condition.submitted">
59+
<dropdown
60+
on-select="$ctrl.selectColumn(selected, $index)"
61+
selected="{ name: condition.columnName || 'Select a value', type: condition.columnType || 'SELECT' }"
62+
options="$ctrl.tableColumns">
63+
</dropdown>
64+
65+
<sql-comparasion-dropdown
66+
selected="condition"
67+
on-select="$ctrl.selectComparasion(selected, $index)"
68+
index="$index"
69+
type="condition.columnType"
70+
ng-if="condition.columnType">
71+
</sql-comparasion-dropdown>
72+
73+
<input
74+
type="text"
75+
class="form-control"
76+
ng-model="condition.comparativeValue"
77+
ng-if="condition.type"
78+
/>
79+
80+
<input
81+
type="text"
82+
class="form-control"
83+
ng-model="condition.comparativeValue2"
84+
ng-if="condition.type === 'BETWEEN'"
85+
/>
86+
87+
<a class="br-button" ng-if="condition.columnName && condition.type && condition.comparativeValue" data-ng-click="$ctrl.saveCondition($index)">
88+
<i title="{{ 'Save' | translate }}" class="fa fa-check"></i>
89+
</a>
90+
</div>
91+
</div>
92+
93+
<button class="br-button" type="button" ng-click="$ctrl.addCondition()">{{ 'Add condition' | translate }}</button>
94+
95+
</div>
96+
97+
<div class="modal-footer">
98+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
99+
<button class="br-button" type="button" ng-click="$ctrl.save()">{{ 'Confirm' | translate }}</button>
100+
</div>

app/angular/components/renameModelModal.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ <h3 class="modal-title">{{ 'Rename model' | translate }}</h3>
55
<div class="modal-body">
66
<form class="form-horizontal" role="form" name="modelForm">
77
<div class="form-group">
8-
<label for="rename-model" class="col-sm-3 control-label">{{ 'Rename' | translate }}</label>
8+
<label for="rename-model" class="col-sm-3 control-label">{{ 'Rename' | translate }}</label>
99
<div class="col-sm-7">
10-
<input
10+
<input
1111
class="form-control"
1212
ng-class="{'error': ($ctrl.name == null || $ctrl.name == '') && $ctrl.submitted}"
13-
type="text"
14-
id="rename-model"
13+
type="text"
14+
id="rename-model"
1515
data-ng-model="$ctrl.name"
1616
placeholder="{{ 'New model name' | translate }}"
1717
autocomplete="off"
@@ -22,6 +22,6 @@ <h3 class="modal-title">{{ 'Rename model' | translate }}</h3>
2222
</div>
2323

2424
<div class="modal-footer">
25-
<button class="br-button yellow" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
25+
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
2626
<button class="br-button" type="button" ng-click="$ctrl.rename($ctrl.name)">{{ 'Rename' | translate }}</button>
2727
</div>

0 commit comments

Comments
 (0)