Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Mobile view options and other small improvements #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"angular-translate": "~2.7.2",
"angularjs-dropdown-multiselect": "mindsmash/angularjs-dropdown-multiselect#b86006bed471db66dd19e46a6e4129f2c3a3bd19",
"checklist-model": "~0.6.0",
"mindsmash-angular-hotkeys": "~1.0.0"
"mindsmash-angular-hotkeys": "~1.0.0",
"angular-media-queries": "~0.4.1"
},
"ignore": [
"**/.*",
Expand Down
43 changes: 30 additions & 13 deletions dist/mindsmash-angular-uxtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@
self.load = function() {
var params = config.requestConverter(config, self);
config.source(params).then(function(response) {
$timeout(function() {
var converted = config.responseConverter(response, self);
var facets = converted.meta.facets;
delete converted.meta.facets;
angular.extend(config, converted.meta);
self.setFacets(facets);
data = converted.data;
$rootScope.$emit('uxTable.dataChanged', data);
$rootScope.$emit('uxTable.configChanged', config);
});
var converted = config.responseConverter(response, self);
var facets = converted.meta.facets;
delete converted.meta.facets;
angular.extend(config, converted.meta);
self.setFacets(facets);
data = converted.data;
$rootScope.$emit('uxTable.dataChanged', data);
$rootScope.$emit('uxTable.configChanged', config);
});
};

Expand Down Expand Up @@ -347,7 +345,10 @@
keyboard: true,
selection: true,
selectionKey: 'id',
rowAction: angular.noop // function(row, idx, api, $event)...
rowAction: angular.noop, // function(row, idx, api, $event)...
mobileViewSize: undefined, // media size to display mobile view (xs,sm,...), multiple values as comma-separated list
mobileViewTemplate: undefined, // replacement template for mobile view (instead of table),
scope: {} // additions/overrides to the scope backing the table (additional action methods etc.)
},
pagination: {
ngClass: 'ux-table-pagination',
Expand Down Expand Up @@ -454,7 +455,7 @@
}];
})

.directive('uxTableView', ['$rootScope', 'hotkeys', 'ElementClickListener', function($rootScope, hotkeys, ElementClickListener) {
.directive('uxTableView', ['$rootScope', 'hotkeys', 'ElementClickListener', 'screenSize', function($rootScope, hotkeys, ElementClickListener, screenSize) {
return {
replace: true,
restrict: 'AE',
Expand Down Expand Up @@ -545,6 +546,16 @@
// initialize
updateConf(null, api.getConfig());
updateData(null, api.getData());

var viewConf = $scope.conf.view;
if (!!viewConf.mobileViewTemplate && !!viewConf.mobileViewSize) {
$scope.mobile = screenSize.is(viewConf.mobileViewSize);
screenSize.on(viewConf.mobileViewSize, function (mobile) {
$scope.mobile = mobile;
});
}

angular.extend($scope, api.getConfig().view.scope);
}
};
}])
Expand Down Expand Up @@ -897,14 +908,20 @@

// ===== INTERNAL

.directive('uxTableCell', ['$compile', function($compile) {
.directive('uxTableCell', ['$compile', '$templateRequest', function($compile, $templateRequest) {
return {
scope: false,
require: '^uxTableView',
link: function($scope, elem, attrs) {
var template = $scope.column.template;
if (angular.isString(template)) {
elem.html($compile(template)($scope));
} else {
if ($scope.column.templateUrl) {
$templateRequest($scope.column.templateUrl).then(function(result) {
elem.html($compile(result)($scope));
});
}
}
}
};
Expand Down
Loading