diff --git a/front/core/components/index.js b/front/core/components/index.js
index 150fc2158..86ab89212 100644
--- a/front/core/components/index.js
+++ b/front/core/components/index.js
@@ -52,4 +52,4 @@ import './wday-picker';
import './datalist';
import './contextmenu';
import './rating';
-import './smart-table-menu';
+import './smart-table';
diff --git a/front/core/components/smart-table-menu/index.js b/front/core/components/smart-table-menu/index.js
deleted file mode 100644
index 9f0d27852..000000000
--- a/front/core/components/smart-table-menu/index.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import ngModule from '../../module';
-import Component from '../../lib/component';
-import './style.scss';
-
-export default class SmartTableMenu extends Component {
- constructor($element, $, $transclude) {
- super($element, $);
- this.$transclude = $transclude;
- // stuff
- }
-
- $onDestroy() {
- if (this.$contentScope)
- this.$contentScope.$destroy();
- }
-
- get model() {
- return this._model;
- }
-
- set model(value) {
- this._model = value;
- if (value)
- this.transclude();
- }
-
- transclude() {
- const body = this.element.querySelector('.body');
- this.$transclude(($clone, $scope) => {
- this.$contentScope = $scope;
- $scope.model = this.model;
- body.appendChild($clone[0]);
- }, null, 'body');
- }
-
- save() {
- this.model.save()
- .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
- }
-}
-
-SmartTableMenu.$inject = ['$element', '$scope', '$transclude'];
-
-ngModule.vnComponent('smartTableMenu', {
- template: require('./index.html'),
- controller: SmartTableMenu,
- transclude: {
- body: '?slotBody'
- },
- bindings: {
- model: ''
- }
-});
diff --git a/front/core/components/smart-table-menu/index.html b/front/core/components/smart-table/index.html
similarity index 69%
rename from front/core/components/smart-table-menu/index.html
rename to front/core/components/smart-table/index.html
index 6cd90efe8..53d015dd4 100644
--- a/front/core/components/smart-table-menu/index.html
+++ b/front/core/components/smart-table/index.html
@@ -1,28 +1,33 @@
\ No newline at end of file
diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js
new file mode 100644
index 000000000..fd22ac9a4
--- /dev/null
+++ b/front/core/components/smart-table/index.js
@@ -0,0 +1,102 @@
+import ngModule from '../../module';
+import Component from '../../lib/component';
+import './style.scss';
+
+export default class SmartTable extends Component {
+ constructor($element, $, $transclude) {
+ super($element, $);
+ this.$transclude = $transclude;
+ // stuff
+ }
+
+ /* $onDestroy() {
+ if (this.$contentScope)
+ this.$contentScope.$destroy();
+ }
+ */
+ get model() {
+ return this._model;
+ }
+
+ set model(value) {
+ this._model = value;
+ if (value) {
+ this.$.model = value;
+ this.transclude();
+ }
+ }
+
+ registerColumns() {
+ const header = this.element.querySelector('thead > tr');
+ if (!header) return;
+ const columns = header.querySelectorAll('th');
+
+ // TODO: Add arrow icon and so on..
+ // Click handler
+ for (let column of columns) {
+ const field = column.getAttribute('field');
+ if (field)
+ column.addEventListener('click', () => this.orderHandler(column));
+ }
+ }
+
+ // Creo que se puede hacer directamente desde ng-transclude
+ transclude() {
+ const slotTable = this.element.querySelector('#table');
+ this.$transclude(($clone, $scope) => {
+ const table = $clone[0];
+ $scope.hasChanges = this.hasChanges;
+ slotTable.appendChild(table);
+ this.registerColumns();
+ }, null, 'table');
+ }
+
+ orderHandler(element) {
+ const field = element.getAttribute('field');
+ console.log(`You clicked to ` + field);
+ }
+
+ createRow() {
+ this.model.insert({
+ nickname: 'New row'
+ });
+ }
+
+ deleteAll() {
+ const data = this.model.data;
+ const checkedRows = data.filter(row => row.checked);
+ for (let row of checkedRows)
+ this.model.remove(row);
+
+ if (this.autoSave)
+ this.save();
+ }
+
+ saveAll() {
+ const model = this.model;
+ if (!model.isChanged)
+ return this.vnApp.showError(this.$t('No changes to save'));
+
+ this.model.save()
+ .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
+ }
+
+ hasChanges() {
+ return true;
+ }
+}
+
+SmartTable.$inject = ['$element', '$scope', '$transclude'];
+
+ngModule.vnComponent('smartTable', {
+ template: require('./index.html'),
+ controller: SmartTable,
+ transclude: {
+ table: '?slotTable',
+ actions: '?slotActions'
+ },
+ bindings: {
+ model: '',
+ autoSave: ''
+ }
+});
diff --git a/front/core/components/smart-table-menu/style.scss b/front/core/components/smart-table/style.scss
similarity index 63%
rename from front/core/components/smart-table-menu/style.scss
rename to front/core/components/smart-table/style.scss
index bb48daef1..15a47d3ec 100644
--- a/front/core/components/smart-table-menu/style.scss
+++ b/front/core/components/smart-table/style.scss
@@ -1,7 +1,7 @@
@import "effects";
@import "variables";
-smart-table-menu {
+smart-table {
.actions-left {
display: flex;
justify-content: flex-start;
@@ -21,4 +21,16 @@ smart-table-menu {
}
}
}
+
+ vn-tbody a[ng-repeat].vn-tr:focus {
+ background-color: $color-primary-light
+ }
+
+ .new-row {
+ background-color: $color-success-light
+ }
+
+ .changed-row {
+ background-color: $color-primary-light
+ }
}
diff --git a/front/core/directives/smart-table2.js b/front/core/directives/smart-table2.js
index 187f77569..916ff130f 100644
--- a/front/core/directives/smart-table2.js
+++ b/front/core/directives/smart-table2.js
@@ -45,7 +45,7 @@ class Controller extends Component {
}
Controller.$inject = ['$element', '$scope', '$attrs'];
-ngModule.directive('smartTable', () => {
+ngModule.directive('smartTable2', () => {
return {
controller: Controller,
bindings: {
diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html
index f3ac18c52..af59eac7d 100644
--- a/modules/ticket/front/index/index.html
+++ b/modules/ticket/front/index/index.html
@@ -1,27 +1,48 @@
-
-
+ -->
+
+
-
-
-
+
+
+ Mas iconos..
+
+
+
- Column 1 |
- Column 2 |
+
+
+
+ |
+ ID |
+ Nickname |
-
-
+
+
+
+
+
+ |
{{::ticket.id}} |
- {{::ticket.userName}} |
+ {{::ticket.nickname}} |
+ |
-
-
-
+
+