Started smart table component
diff --git a/views/ngXosLib/xosHelpers/spec/ui/smart-table.test.js b/views/ngXosLib/xosHelpers/spec/ui/smart-table.test.js
new file mode 100644
index 0000000..95b7d4b
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/spec/ui/smart-table.test.js
@@ -0,0 +1,55 @@
+/**
+ * © OpenCORD
+ *
+ * Created by teone on 3/24/16.
+ */
+
+(function () {
+ 'use strict';
+
+ describe('The xos.helper module', function(){
+ describe('The xos-smart-table component', () => {
+
+ let spy, scope, isolatedScope, element;
+
+ beforeEach(module('xos.helpers'));
+
+ // mock the service
+ beforeEach(function(){
+ module(function($provide){
+ $provide.service('MockResource', function(){
+ this.test = (msg) => console.log(msg);
+ this.query = jasmine.createSpy('add')
+ .and.returnValue({$promise: cb => {
+ console.log('------------------ CB ------------------');
+ return cb([]);
+ }});
+ });
+ });
+ })
+
+ beforeEach(inject(function ($compile, $rootScope, MockResource) {
+ scope = $rootScope.$new();
+
+ scope.config = {
+ resource: 'MockResource'
+ };
+
+ spy = MockResource;
+ // console.log(MockResource.query.toString(), spy.query.toString());
+
+ element = angular.element('<xos-smart-table config="config"></xos-smart-table>');
+ $compile(element)(scope);
+ scope.$digest();
+ isolatedScope = element.isolateScope().vm;
+ }));
+
+ it('should query elements', () => {
+
+ console.log(spy.query.toString());
+ expect(spy.query).toHaveBeenCalled();
+ });
+
+ });
+ });
+})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
index 3feeb4a..b8b5915 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
@@ -57,9 +57,11 @@
let Resource = $injector.get(this.config.resource);
+ console.log('query', Resource.query.toString(), Resource.test(`I'm Alive!`));
+
Resource.query().$promise
.then((res) => {
-
+ console.log('Data!!');
let props = Object.keys(res[0]);
_.remove(props, p => {
diff --git a/views/ngXosViews/sampleView/env/default.js b/views/ngXosViews/sampleView/env/default.js
index dacf8e8..053be99 100644
--- a/views/ngXosViews/sampleView/env/default.js
+++ b/views/ngXosViews/sampleView/env/default.js
@@ -8,6 +8,6 @@
module.exports = {
host: 'http://xos.dev:9999/',
- xoscsrftoken: 'q7gXR35WCSa2R9njrZJiubGCUxGR40tX',
- xossessionid: 'ghzz0lxwt8f7z5io9gj8ni9yrrrkgz17'
+ xoscsrftoken: 'OwZOjlUUKSXGNbGkJsBPT9sPyEABXl8G',
+ xossessionid: 'uk0a1z9gbm5leb1tgrdyfsb48uc9sakv'
};
diff --git a/views/ngXosViews/sampleView/src/index.html b/views/ngXosViews/sampleView/src/index.html
index 2693838..593e982 100644
--- a/views/ngXosViews/sampleView/src/index.html
+++ b/views/ngXosViews/sampleView/src/index.html
@@ -3,8 +3,8 @@
<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.min.css" />
<!-- endbower --><!-- endcss -->
<!-- inject:css -->
-<link rel="stylesheet" href="/../../../xos/core/static/xosNgLib.css">
<link rel="stylesheet" href="/css/main.css">
+<link rel="stylesheet" href="/../../../xos/core/static/xosNgLib.css">
<!-- endinject -->
<div ng-cloak ng-app="xos.sampleView" id="xosSampleView" class="container-fluid">
diff --git a/views/ngXosViews/sampleView/src/js/main.js b/views/ngXosViews/sampleView/src/js/main.js
index d3aa494..5f7be4d 100644
--- a/views/ngXosViews/sampleView/src/js/main.js
+++ b/views/ngXosViews/sampleView/src/js/main.js
@@ -59,6 +59,10 @@
}
};
+ this.smartTableConfig = {
+ resource: 'Users'
+ }
+
this.alertConfig = {
type: 'danger',
closeBtn: true
diff --git a/views/ngXosViews/sampleView/src/templates/users-list.tpl.html b/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
index c1f7b20..a0902cd 100644
--- a/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
+++ b/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
@@ -7,17 +7,18 @@
<div class="row">
<div class="col-xs-12">
- <xos-form ng-model="vm.users[0]" config="vm.formConfig"></xos-form>
+ <!-- <xos-form ng-model="vm.users[0]" config="vm.formConfig"></xos-form>
<xos-alert config="vm.alertConfig">Random alert</xos-alert>
<a class="btn" ng-click="vm.errors.email = !vm.errors.email" ng-class="{'btn-default': !vm.errors.email, 'btn-success': vm.errors.email}">
Email
- </a>
- <xos-validation errors="vm.errors"></xos-validation>
+ </a> -->
+ <!-- <xos-validation errors="vm.errors"></xos-validation> -->
</div>
</div>
<div class="row">
<div class="col-xs-12">
- <xos-table data="vm.users" config="vm.tableConfig"></xos-table>
+ <!-- <xos-table config="vm.tableConfig"></xos-table> -->
+ <xos-smart-table config="vm.smartTableConfig"></xos-smart-table>
</div>
</div>
\ No newline at end of file
diff --git a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
index c56b8dd..f957a2f 100644
--- a/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
+++ b/xos/core/xoslib/static/js/vendor/ngXosHelpers.js
@@ -28,6 +28,98 @@
*
* Visit http://guide.xosproject.org/devguide/addview/ for more information
*
+ * Created by teone on 3/24/16.
+ */
+
+(function () {
+ 'use strict';
+
+ angular.module('xos.uiComponents')
+
+ /**
+ * @ngdoc directive
+ * @name xos.uiComponents.directive:xosSmartTable
+ * @restrict E
+ * @description The xos-table directive
+ * @param {Object} config The configuration for the component.
+ * @scope
+ * @example
+ */
+
+ .directive('xosSmartTable', function () {
+ return {
+ restrict: 'E',
+ scope: {
+ config: '='
+ },
+ template: '\n <xos-table config="vm.tableConfig" data="vm.data"></xos-table>\n ',
+ bindToController: true,
+ controllerAs: 'vm',
+ controller: ["$injector", "LabelFormatter", "_", function controller($injector, LabelFormatter, _) {
+ var _this = this;
+
+ this.tableConfig = {
+ columns: [],
+ // actions: [
+ // {
+ // label: 'delete',
+ // icon: 'remove',
+ // cb: (user) => {
+ // console.log(user);
+ // // _.remove(this.users, {id: user.id});
+ // },
+ // color: 'red'
+ // }
+ // ],
+ filter: 'field',
+ order: true,
+ pagination: {
+ pageSize: 10
+ }
+ };
+
+ var Resource = $injector.get(this.config.resource);
+
+ console.log('query', Resource.query.toString(), Resource.test('I\'m Alive!'));
+
+ Resource.query().$promise.then(function (res) {
+ console.log('Data!!');
+ var props = Object.keys(res[0]);
+
+ _.remove(props, function (p) {
+ return p == 'id' || p == 'password' || p == 'validators';
+ });
+
+ var labels = props.map(function (p) {
+ return LabelFormatter.format(p);
+ });
+
+ console.log(props, labels);
+
+ props.forEach(function (p, i) {
+ _this.tableConfig.columns.push({
+ label: labels[i],
+ prop: p
+ });
+ });
+
+ console.log(_this.tableConfig.columns);
+
+ _this.data = res;
+ });
+ }]
+ };
+ });
+})();
+//# sourceMappingURL=../../../maps/ui_components/smartComponents/smartTable/smartTable.component.js.map
+
+'use strict';
+
+/**
+ * © OpenCORD
+ *
+ * Visit http://guide.xosproject.org/devguide/addview/ for more information
+ *
* Created by teone on 4/15/16.
*/