angular-smart-table
Advanced tools
Comparing version 2.0.2 to 2.1.0
{ | ||
"name": "angular-smart-table", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"homepage": "https://github.com/lorenzofox3/Smart-Table", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -130,2 +130,14 @@ ## version 1.1.0 | ||
* add debounce to custom pipe function to make sure tableState is stable | ||
* fix #329 | ||
* fix #329 | ||
## version 2.0.3 | ||
* implements #379 | ||
* fix #390 | ||
## version 2.1.0 | ||
* support nested search (thanks to @jansabbe) | ||
* fix #254 | ||
* fix wrong path to default config for stSkipNatural (@phuvo) | ||
* fix #406 |
/** | ||
* @version 2.0.2 | ||
* @version 2.1.0 | ||
* @license MIT | ||
@@ -10,3 +10,3 @@ */ | ||
$templateCache.put('template/smart-table/pagination.html', | ||
'<nav ng-if="pages.length >= 2"><ul class="pagination">' + | ||
'<nav ng-if="numPages && pages.length >= 2"><ul class="pagination">' + | ||
'<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li>' + | ||
@@ -25,3 +25,4 @@ '</ul></nav>'); | ||
search: { | ||
delay: 400 // ms | ||
delay: 400, // ms | ||
inputEvent: 'input' | ||
}, | ||
@@ -34,3 +35,4 @@ select: { | ||
ascentClass: 'st-sort-ascent', | ||
descentClass: 'st-sort-descent' | ||
descentClass: 'st-sort-descent', | ||
skipNatural: false | ||
}, | ||
@@ -73,2 +75,17 @@ pipe: { | ||
function deepDelete(object, path) { | ||
if (path.indexOf('.') != -1) { | ||
var partials = path.split('.'); | ||
var key = partials.pop(); | ||
var parentPath = partials.join('.'); | ||
var parentObject = $parse(parentPath)(object) | ||
delete parentObject[key]; | ||
if (Object.keys(parentObject).length == 0) { | ||
deepDelete(object, parentPath); | ||
} | ||
} else { | ||
delete object[path]; | ||
} | ||
} | ||
if ($attrs.stSafeSrc) { | ||
@@ -123,6 +140,6 @@ safeGetter = $parse($attrs.stSafeSrc); | ||
input = ng.isString(input) ? input.trim() : input; | ||
predicateObject[prop] = input; | ||
$parse(prop).assign(predicateObject, input); | ||
// to avoid to filter out null value | ||
if (!input) { | ||
delete predicateObject[prop]; | ||
deepDelete(predicateObject, prop); | ||
} | ||
@@ -158,3 +175,3 @@ tableState.search.predicateObject = predicateObject; | ||
this.select = function select (row, mode) { | ||
var rows = safeCopy; | ||
var rows = copyRefs(displayGetter($scope)); | ||
var index = rows.indexOf(row); | ||
@@ -240,3 +257,3 @@ if (index !== -1) { | ||
ng.module('smart-table') | ||
.directive('stSearch', ['stConfig', '$timeout', function (stConfig, $timeout) { | ||
.directive('stSearch', ['stConfig', '$timeout','$parse', function (stConfig, $timeout, $parse) { | ||
return { | ||
@@ -248,2 +265,3 @@ require: '^stTable', | ||
var throttle = attr.stDelay || stConfig.search.delay; | ||
var event = attr.stInputEvent || stConfig.search.inputEvent; | ||
@@ -263,4 +281,4 @@ attr.$observe('stSearch', function (newValue, oldValue) { | ||
var predicateExpression = attr.stSearch || '$'; | ||
if (newValue.predicateObject && newValue.predicateObject[predicateExpression] !== element[0].value) { | ||
element[0].value = newValue.predicateObject[predicateExpression] || ''; | ||
if (newValue.predicateObject && $parse(predicateExpression)(newValue.predicateObject) !== element[0].value) { | ||
element[0].value = $parse(predicateExpression)(newValue.predicateObject) || ''; | ||
} | ||
@@ -270,3 +288,3 @@ }, true); | ||
// view -> table state | ||
element.bind('input', function (evt) { | ||
element.bind(event, function (evt) { | ||
evt = evt.originalEvent || evt; | ||
@@ -327,2 +345,3 @@ if (promise !== null) { | ||
var sortDefault; | ||
var skipNatural = attr.stSkipNatural !== undefined ? attr.stSkipNatural : stConfig.sort.skipNatural; | ||
@@ -337,3 +356,3 @@ if (attr.stSortDefault) { | ||
predicate = ng.isFunction(getter(scope)) ? getter(scope) : attr.stSort; | ||
if (index % 3 === 0 && attr.stSkipNatural === undefined) { | ||
if (index % 3 === 0 && !!skipNatural !== true) { | ||
//manual reset | ||
@@ -498,2 +517,2 @@ index = 0; | ||
})(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Rpb24ubnVtYmVyKSB7XG4gICAgICAgICAgY3RybC5zbGljZSgwLCBzY29wZS5zdEl0ZW1zQnlQYWdlKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH07XG4gIH1dKTtcbiIsIm5nLm1vZHVsZSgnc21hcnQtdGFibGUnKVxuICAuZGlyZWN0aXZlKCdzdFBpcGUnLCBbJ3N0Q29uZmlnJywgJyR0aW1lb3V0JywgZnVuY3Rpb24gKGNvbmZpZywgJHRpbWVvdXQpIHtcbiAgICByZXR1cm4ge1xuICAgICAgcmVxdWlyZTogJ3N0VGFibGUnLFxuICAgICAgc2NvcGU6IHtcbiAgICAgICAgc3RQaXBlOiAnPSdcbiAgICAgIH0sXG4gICAgICBsaW5rOiB7XG5cbiAgICAgICAgcHJlOiBmdW5jdGlvbiAoc2NvcGUsIGVsZW1lbnQsIGF0dHJzLCBjdHJsKSB7XG5cbiAgICAgICAgICB2YXIgcGlwZVByb21pc2UgPSBudWxsO1xuXG4gICAgICAgICAgaWYgKG5nLmlzRnVuY3Rpb24oc2NvcGUuc3RQaXBlKSkge1xuICAgICAgICAgICAgY3RybC5wcmV2ZW50UGlwZU9uV2F0Y2goKTtcbiAgICAgICAgICAgIGN0cmwucGlwZSA9IGZ1bmN0aW9uICgpIHtcblxuICAgICAgICAgICAgICBpZiAocGlwZVByb21pc2UgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAkdGltZW91dC5jYW5jZWwocGlwZVByb21pc2UpXG4gICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICBwaXBlUHJvbWlzZSA9ICR0aW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBzY29wZS5zdFBpcGUoY3RybC50YWJsZVN0YXRlKCksIGN0cmwpO1xuICAgICAgICAgICAgICB9LCBjb25maWcucGlwZS5kZWxheSk7XG5cbiAgICAgICAgICAgICAgcmV0dXJuIHBpcGVQcm9taXNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cb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YgISFza2lwTmF0dXJhbCAhPT0gdHJ1ZSkge1xuICAgICAgICAgICAgLy9tYW51YWwgcmVzZXRcbiAgICAgICAgICAgIGluZGV4ID0gMDtcbiAgICAgICAgICAgIGN0cmwudGFibGVTdGF0ZSgpLnNvcnQgPSB7fTtcbiAgICAgICAgICAgIGN0cmwudGFibGVTdGF0ZSgpLnBhZ2luYXRpb24uc3RhcnQgPSAwO1xuICAgICAgICAgICAgY3RybC5waXBlKCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGN0cmwuc29ydEJ5KHByZWRpY2F0ZSwgaW5kZXggJSAyID09PSAwKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBlbGVtZW50LmJpbmQoJ2NsaWNrJywgZnVuY3Rpb24gc29ydENsaWNrICgpIHtcbiAgICAgICAgICBpZiAocHJlZGljYXRlKSB7XG4gICAgICAgICAgICBzY29wZS4kYXBwbHkoc29ydCk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBpZiAoc29ydERlZmF1bHQpIHtcbiAgICAgICAgICBpbmRleCA9IHNvcnREZWZhdWx0ID09PSAncmV2ZXJzZScgPyAxIDogMDtcbiAgICAgICAgICBzb3J0KCk7XG4gICAgICAgIH1cblxuICAgICAgICAvL3RhYmxlIHN0YXRlIC0tPiB2aWV3XG4gICAgICAgIHNjb3BlLiR3YXRjaChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgcmV0dXJuIGN0cmwudGFibGVTdGF0ZSgpLnNvcnQ7XG4gICAgICAgIH0sIGZ1bmN0aW9uIChuZXdWYWx1ZSkge1xuICAgICAgICAgIGlmIChuZXdWYWx1ZS5wcmVkaWNhdGUgIT09IHByZWRpY2F0ZSkge1xuICAgICAgICAgICAgaW5kZXggPSAwO1xuICAgICAgICAgICAgZWxlbWVudFxuICAgICAgICAgICAgICAucmVtb3ZlQ2xhc3MoY2xhc3NBc2NlbnQpXG4gICAgICAgICAgICAgIC5y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udWxsKSB7XG4gICAgICAgICAgICAgICAgJHRpbWVvdXQuY2FuY2VsKHBpcGVQcm9taXNlKVxuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgcGlwZVByb21pc2UgPSAkdGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgc2NvcGUuc3RQaXBlKGN0cmwudGFibGVTdGF0ZSgpLCBjdHJsKTtcbiAgICAgICAgICAgICAgfSwgY29uZmlnLnBpcGUuZGVsYXkpO1xuXG4gICAgICAgICAgICAgIHJldHVybiBwaXBlUHJvbWlzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG5cbiAgICAgICAgcG9zdDogZnVuY3Rpb24gKHNjb3BlLCBlbGVtZW50LCBhdHRycywgY3RybCkge1xuICAgICAgICAgIGN0cmwucGlwZSgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfTtcbiAgfV0pO1xuIiwifSkoYW5ndWxhcik7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9 |
/** | ||
* @version 2.0.2 | ||
* @version 2.1.0 | ||
* @license MIT | ||
*/ | ||
!function(t,e){"use strict";t.module("smart-table",[]).run(["$templateCache",function(t){t.put("template/smart-table/pagination.html",'<nav ng-if="pages.length >= 2"><ul class="pagination"><li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li></ul></nav>')}]),t.module("smart-table").constant("stConfig",{pagination:{template:"template/smart-table/pagination.html",itemsByPage:10,displayedPages:5},search:{delay:400},select:{mode:"single",selectedClass:"st-selected"},sort:{ascentClass:"st-sort-ascent",descentClass:"st-sort-descent"},pipe:{delay:100}}),t.module("smart-table").controller("stTableController",["$scope","$parse","$filter","$attrs",function(a,s,n,r){function i(t){return t?[].concat(t):[]}function c(){h=i(l(a)),P===!0&&S.pipe()}var l,o,u,p=r.stTable,g=s(p),f=g.assign,d=n("orderBy"),m=n("filter"),h=i(g(a)),b={sort:{},search:{},pagination:{start:0}},P=!0,S=this;r.stSafeSrc&&(l=s(r.stSafeSrc),a.$watch(function(){var t=l(a);return t?t.length:0},function(t){t!==h.length&&c()}),a.$watch(function(){return l(a)},function(t,e){t!==e&&c()})),this.sortBy=function(e,a){return b.sort.predicate=e,b.sort.reverse=a===!0,t.isFunction(e)?b.sort.functionName=e.name:delete b.sort.functionName,b.pagination.start=0,this.pipe()},this.search=function(e,a){var s=b.search.predicateObject||{},n=a?a:"$";return e=t.isString(e)?e.trim():e,s[n]=e,e||delete s[n],b.search.predicateObject=s,b.pagination.start=0,this.pipe()},this.pipe=function(){var t,s=b.pagination;o=b.search.predicateObject?m(h,b.search.predicateObject):h,b.sort.predicate&&(o=d(o,b.sort.predicate,b.sort.reverse)),s.number!==e&&(s.numberOfPages=o.length>0?Math.ceil(o.length/s.number):1,s.start=s.start>=o.length?(s.numberOfPages-1)*s.number:s.start,t=o.slice(s.start,s.start+parseInt(s.number))),f(a,t||o)},this.select=function(t,a){var s=h,n=s.indexOf(t);-1!==n&&("single"===a?(t.isSelected=t.isSelected!==!0,u&&(u.isSelected=!1),u=t.isSelected===!0?t:e):s[n].isSelected=!s[n].isSelected)},this.slice=function(t,e){return b.pagination.start=t,b.pagination.number=e,this.pipe()},this.tableState=function(){return b},this.getFilteredCollection=function(){return o||h},this.setFilterFunction=function(t){m=n(t)},this.setSortFunction=function(t){d=n(t)},this.preventPipeOnWatch=function(){P=!1}}]).directive("stTable",function(){return{restrict:"A",controller:"stTableController",link:function(t,e,a,s){a.stSetFilter&&s.setFilterFunction(a.stSetFilter),a.stSetSort&&s.setSortFunction(a.stSetSort)}}}),t.module("smart-table").directive("stSearch",["stConfig","$timeout",function(t,e){return{require:"^stTable",link:function(a,s,n,r){var i=r,c=null,l=n.stDelay||t.search.delay;n.$observe("stSearch",function(t,e){var a=s[0].value;t!==e&&a&&(r.tableState().search={},i.search(a,t))}),a.$watch(function(){return r.tableState().search},function(t){var e=n.stSearch||"$";t.predicateObject&&t.predicateObject[e]!==s[0].value&&(s[0].value=t.predicateObject[e]||"")},!0),s.bind("input",function(t){t=t.originalEvent||t,null!==c&&e.cancel(c),c=e(function(){i.search(t.target.value,n.stSearch||""),c=null},l)})}}}]),t.module("smart-table").directive("stSelectRow",["stConfig",function(t){return{restrict:"A",require:"^stTable",scope:{row:"=stSelectRow"},link:function(e,a,s,n){var r=s.stSelectMode||t.select.mode;a.bind("click",function(){e.$apply(function(){n.select(e.row,r)})}),e.$watch("row.isSelected",function(e){e===!0?a.addClass(t.select.selectedClass):a.removeClass(t.select.selectedClass)})}}}]),t.module("smart-table").directive("stSort",["stConfig","$parse",function(a,s){return{restrict:"A",require:"^stTable",link:function(n,r,i,c){function l(){g++,u=t.isFunction(p(n))?p(n):i.stSort,g%3===0&&i.stSkipNatural===e?(g=0,c.tableState().sort={},c.tableState().pagination.start=0,c.pipe()):c.sortBy(u,g%2===0)}var o,u=i.stSort,p=s(u),g=0,f=i.stClassAscent||a.sort.ascentClass,d=i.stClassDescent||a.sort.descentClass,m=[f,d];i.stSortDefault&&(o=n.$eval(i.stSortDefault)!==e?n.$eval(i.stSortDefault):i.stSortDefault),r.bind("click",function(){u&&n.$apply(l)}),o&&(g="reverse"===o?1:0,l()),n.$watch(function(){return c.tableState().sort},function(t){t.predicate!==u?(g=0,r.removeClass(f).removeClass(d)):(g=t.reverse===!0?2:1,r.removeClass(m[g%2]).addClass(m[g-1]))},!0)}}}]),t.module("smart-table").directive("stPagination",["stConfig",function(t){return{restrict:"EA",require:"^stTable",scope:{stItemsByPage:"=?",stDisplayedPages:"=?",stPageChange:"&"},templateUrl:function(e,a){return a.stTemplate?a.stTemplate:t.pagination.template},link:function(e,a,s,n){function r(){var t,a,s=n.tableState().pagination,r=1,i=e.currentPage;for(e.currentPage=Math.floor(s.start/s.number)+1,r=Math.max(r,e.currentPage-Math.abs(Math.floor(e.stDisplayedPages/2))),t=r+e.stDisplayedPages,t>s.numberOfPages&&(t=s.numberOfPages+1,r=Math.max(1,t-e.stDisplayedPages)),e.pages=[],e.numPages=s.numberOfPages,a=r;t>a;a++)e.pages.push(a);i!==e.currentPage&&e.stPageChange({newPage:e.currentPage})}e.stItemsByPage=e.stItemsByPage?+e.stItemsByPage:t.pagination.itemsByPage,e.stDisplayedPages=e.stDisplayedPages?+e.stDisplayedPages:t.pagination.displayedPages,e.currentPage=1,e.pages=[],e.$watch(function(){return n.tableState().pagination},r,!0),e.$watch("stItemsByPage",function(t,a){t!==a&&e.selectPage(1)}),e.$watch("stDisplayedPages",r),e.selectPage=function(t){t>0&&t<=e.numPages&&n.slice((t-1)*e.stItemsByPage,e.stItemsByPage)},n.tableState().pagination.number||n.slice(0,e.stItemsByPage)}}}]),t.module("smart-table").directive("stPipe",["stConfig","$timeout",function(e,a){return{require:"stTable",scope:{stPipe:"="},link:{pre:function(s,n,r,i){var c=null;t.isFunction(s.stPipe)&&(i.preventPipeOnWatch(),i.pipe=function(){return null!==c&&a.cancel(c),c=a(function(){s.stPipe(i.tableState(),i)},e.pipe.delay)})},post:function(t,e,a,s){s.pipe()}}}}])}(angular); | ||
!function(t,e){"use strict";t.module("smart-table",[]).run(["$templateCache",function(t){t.put("template/smart-table/pagination.html",'<nav ng-if="numPages && pages.length >= 2"><ul class="pagination"><li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li></ul></nav>')}]),t.module("smart-table").constant("stConfig",{pagination:{template:"template/smart-table/pagination.html",itemsByPage:10,displayedPages:5},search:{delay:400,inputEvent:"input"},select:{mode:"single",selectedClass:"st-selected"},sort:{ascentClass:"st-sort-ascent",descentClass:"st-sort-descent",skipNatural:!1},pipe:{delay:100}}),t.module("smart-table").controller("stTableController",["$scope","$parse","$filter","$attrs",function(a,s,n,i){function r(t){return t?[].concat(t):[]}function c(){b=r(o(a)),S===!0&&v.pipe()}function l(t,e){if(-1!=e.indexOf(".")){var a=e.split("."),n=a.pop(),i=a.join("."),r=s(i)(t);delete r[n],0==Object.keys(r).length&&l(t,i)}else delete t[e]}var o,u,p,g=i.stTable,f=s(g),d=f.assign,m=n("orderBy"),h=n("filter"),b=r(f(a)),P={sort:{},search:{},pagination:{start:0}},S=!0,v=this;i.stSafeSrc&&(o=s(i.stSafeSrc),a.$watch(function(){var t=o(a);return t?t.length:0},function(t){t!==b.length&&c()}),a.$watch(function(){return o(a)},function(t,e){t!==e&&c()})),this.sortBy=function(e,a){return P.sort.predicate=e,P.sort.reverse=a===!0,t.isFunction(e)?P.sort.functionName=e.name:delete P.sort.functionName,P.pagination.start=0,this.pipe()},this.search=function(e,a){var n=P.search.predicateObject||{},i=a?a:"$";return e=t.isString(e)?e.trim():e,s(i).assign(n,e),e||l(n,i),P.search.predicateObject=n,P.pagination.start=0,this.pipe()},this.pipe=function(){var t,s=P.pagination;u=P.search.predicateObject?h(b,P.search.predicateObject):b,P.sort.predicate&&(u=m(u,P.sort.predicate,P.sort.reverse)),s.number!==e&&(s.numberOfPages=u.length>0?Math.ceil(u.length/s.number):1,s.start=s.start>=u.length?(s.numberOfPages-1)*s.number:s.start,t=u.slice(s.start,s.start+parseInt(s.number))),d(a,t||u)},this.select=function(t,s){var n=r(f(a)),i=n.indexOf(t);-1!==i&&("single"===s?(t.isSelected=t.isSelected!==!0,p&&(p.isSelected=!1),p=t.isSelected===!0?t:e):n[i].isSelected=!n[i].isSelected)},this.slice=function(t,e){return P.pagination.start=t,P.pagination.number=e,this.pipe()},this.tableState=function(){return P},this.getFilteredCollection=function(){return u||b},this.setFilterFunction=function(t){h=n(t)},this.setSortFunction=function(t){m=n(t)},this.preventPipeOnWatch=function(){S=!1}}]).directive("stTable",function(){return{restrict:"A",controller:"stTableController",link:function(t,e,a,s){a.stSetFilter&&s.setFilterFunction(a.stSetFilter),a.stSetSort&&s.setSortFunction(a.stSetSort)}}}),t.module("smart-table").directive("stSearch",["stConfig","$timeout","$parse",function(t,e,a){return{require:"^stTable",link:function(s,n,i,r){var c=r,l=null,o=i.stDelay||t.search.delay,u=i.stInputEvent||t.search.inputEvent;i.$observe("stSearch",function(t,e){var a=n[0].value;t!==e&&a&&(r.tableState().search={},c.search(a,t))}),s.$watch(function(){return r.tableState().search},function(t){var e=i.stSearch||"$";t.predicateObject&&a(e)(t.predicateObject)!==n[0].value&&(n[0].value=a(e)(t.predicateObject)||"")},!0),n.bind(u,function(t){t=t.originalEvent||t,null!==l&&e.cancel(l),l=e(function(){c.search(t.target.value,i.stSearch||""),l=null},o)})}}}]),t.module("smart-table").directive("stSelectRow",["stConfig",function(t){return{restrict:"A",require:"^stTable",scope:{row:"=stSelectRow"},link:function(e,a,s,n){var i=s.stSelectMode||t.select.mode;a.bind("click",function(){e.$apply(function(){n.select(e.row,i)})}),e.$watch("row.isSelected",function(e){e===!0?a.addClass(t.select.selectedClass):a.removeClass(t.select.selectedClass)})}}}]),t.module("smart-table").directive("stSort",["stConfig","$parse",function(a,s){return{restrict:"A",require:"^stTable",link:function(n,i,r,c){function l(){g++,u=t.isFunction(p(n))?p(n):r.stSort,g%3===0&&!!h!=!0?(g=0,c.tableState().sort={},c.tableState().pagination.start=0,c.pipe()):c.sortBy(u,g%2===0)}var o,u=r.stSort,p=s(u),g=0,f=r.stClassAscent||a.sort.ascentClass,d=r.stClassDescent||a.sort.descentClass,m=[f,d],h=r.stSkipNatural!==e?r.stSkipNatural:a.sort.skipNatural;r.stSortDefault&&(o=n.$eval(r.stSortDefault)!==e?n.$eval(r.stSortDefault):r.stSortDefault),i.bind("click",function(){u&&n.$apply(l)}),o&&(g="reverse"===o?1:0,l()),n.$watch(function(){return c.tableState().sort},function(t){t.predicate!==u?(g=0,i.removeClass(f).removeClass(d)):(g=t.reverse===!0?2:1,i.removeClass(m[g%2]).addClass(m[g-1]))},!0)}}}]),t.module("smart-table").directive("stPagination",["stConfig",function(t){return{restrict:"EA",require:"^stTable",scope:{stItemsByPage:"=?",stDisplayedPages:"=?",stPageChange:"&"},templateUrl:function(e,a){return a.stTemplate?a.stTemplate:t.pagination.template},link:function(e,a,s,n){function i(){var t,a,s=n.tableState().pagination,i=1,r=e.currentPage;for(e.currentPage=Math.floor(s.start/s.number)+1,i=Math.max(i,e.currentPage-Math.abs(Math.floor(e.stDisplayedPages/2))),t=i+e.stDisplayedPages,t>s.numberOfPages&&(t=s.numberOfPages+1,i=Math.max(1,t-e.stDisplayedPages)),e.pages=[],e.numPages=s.numberOfPages,a=i;t>a;a++)e.pages.push(a);r!==e.currentPage&&e.stPageChange({newPage:e.currentPage})}e.stItemsByPage=e.stItemsByPage?+e.stItemsByPage:t.pagination.itemsByPage,e.stDisplayedPages=e.stDisplayedPages?+e.stDisplayedPages:t.pagination.displayedPages,e.currentPage=1,e.pages=[],e.$watch(function(){return n.tableState().pagination},i,!0),e.$watch("stItemsByPage",function(t,a){t!==a&&e.selectPage(1)}),e.$watch("stDisplayedPages",i),e.selectPage=function(t){t>0&&t<=e.numPages&&n.slice((t-1)*e.stItemsByPage,e.stItemsByPage)},n.tableState().pagination.number||n.slice(0,e.stItemsByPage)}}}]),t.module("smart-table").directive("stPipe",["stConfig","$timeout",function(e,a){return{require:"stTable",scope:{stPipe:"="},link:{pre:function(s,n,i,r){var c=null;t.isFunction(s.stPipe)&&(r.preventPipeOnWatch(),r.pipe=function(){return null!==c&&a.cancel(c),c=a(function(){s.stPipe(r.tableState(),r)},e.pipe.delay)})},post:function(t,e,a,s){s.pipe()}}}}])}(angular); |
{ | ||
"name": "angular-smart-table", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/smart-table.js", |
ng.module('smart-table', []).run(['$templateCache', function ($templateCache) { | ||
$templateCache.put('template/smart-table/pagination.html', | ||
'<nav ng-if="pages.length >= 2"><ul class="pagination">' + | ||
'<nav ng-if="numPages && pages.length >= 2"><ul class="pagination">' + | ||
'<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li>' + | ||
@@ -5,0 +5,0 @@ '</ul></nav>'); |
@@ -9,3 +9,4 @@ ng.module('smart-table') | ||
search: { | ||
delay: 400 // ms | ||
delay: 400, // ms | ||
inputEvent: 'input' | ||
}, | ||
@@ -18,3 +19,4 @@ select: { | ||
ascentClass: 'st-sort-ascent', | ||
descentClass: 'st-sort-descent' | ||
descentClass: 'st-sort-descent', | ||
skipNatural: false | ||
}, | ||
@@ -21,0 +23,0 @@ pipe: { |
ng.module('smart-table') | ||
.directive('stSearch', ['stConfig', '$timeout', function (stConfig, $timeout) { | ||
.directive('stSearch', ['stConfig', '$timeout','$parse', function (stConfig, $timeout, $parse) { | ||
return { | ||
@@ -9,2 +9,3 @@ require: '^stTable', | ||
var throttle = attr.stDelay || stConfig.search.delay; | ||
var event = attr.stInputEvent || stConfig.search.inputEvent; | ||
@@ -24,4 +25,4 @@ attr.$observe('stSearch', function (newValue, oldValue) { | ||
var predicateExpression = attr.stSearch || '$'; | ||
if (newValue.predicateObject && newValue.predicateObject[predicateExpression] !== element[0].value) { | ||
element[0].value = newValue.predicateObject[predicateExpression] || ''; | ||
if (newValue.predicateObject && $parse(predicateExpression)(newValue.predicateObject) !== element[0].value) { | ||
element[0].value = $parse(predicateExpression)(newValue.predicateObject) || ''; | ||
} | ||
@@ -31,3 +32,3 @@ }, true); | ||
// view -> table state | ||
element.bind('input', function (evt) { | ||
element.bind(event, function (evt) { | ||
evt = evt.originalEvent || evt; | ||
@@ -34,0 +35,0 @@ if (promise !== null) { |
@@ -15,2 +15,3 @@ ng.module('smart-table') | ||
var sortDefault; | ||
var skipNatural = attr.stSkipNatural !== undefined ? attr.stSkipNatural : stConfig.sort.skipNatural; | ||
@@ -25,3 +26,3 @@ if (attr.stSortDefault) { | ||
predicate = ng.isFunction(getter(scope)) ? getter(scope) : attr.stSort; | ||
if (index % 3 === 0 && attr.stSkipNatural === undefined) { | ||
if (index % 3 === 0 && !!skipNatural !== true) { | ||
//manual reset | ||
@@ -28,0 +29,0 @@ index = 0; |
@@ -33,2 +33,17 @@ ng.module('smart-table') | ||
function deepDelete(object, path) { | ||
if (path.indexOf('.') != -1) { | ||
var partials = path.split('.'); | ||
var key = partials.pop(); | ||
var parentPath = partials.join('.'); | ||
var parentObject = $parse(parentPath)(object) | ||
delete parentObject[key]; | ||
if (Object.keys(parentObject).length == 0) { | ||
deepDelete(object, parentPath); | ||
} | ||
} else { | ||
delete object[path]; | ||
} | ||
} | ||
if ($attrs.stSafeSrc) { | ||
@@ -83,6 +98,6 @@ safeGetter = $parse($attrs.stSafeSrc); | ||
input = ng.isString(input) ? input.trim() : input; | ||
predicateObject[prop] = input; | ||
$parse(prop).assign(predicateObject, input); | ||
// to avoid to filter out null value | ||
if (!input) { | ||
delete predicateObject[prop]; | ||
deepDelete(predicateObject, prop); | ||
} | ||
@@ -118,3 +133,3 @@ tableState.search.predicateObject = predicateObject; | ||
this.select = function select (row, mode) { | ||
var rows = safeCopy; | ||
var rows = copyRefs(displayGetter($scope)); | ||
var index = rows.indexOf(row); | ||
@@ -121,0 +136,0 @@ if (index !== -1) { |
@@ -197,3 +197,2 @@ describe('stSearch Directive', function () { | ||
it('should support binding on search predicate', inject(function ($compile, $timeout) { | ||
@@ -229,2 +228,89 @@ scope.searchPredicate = 'name'; | ||
}); | ||
describe('deep object predicate', function () { | ||
beforeEach(inject(function ($compile, $rootScope) { | ||
rootScope = $rootScope; | ||
scope = $rootScope.$new(); | ||
scope.rowCollection = [ | ||
{name: {lastname: 'Renard', firstname: 'Laurent'}, age: 66, description:'really silly description'}, | ||
{name: {lastname: 'Francoise', firstname: 'Frere'}, age: 99, description:'really silly description'}, | ||
{name: {lastname: 'Renard', firstname: 'Olivier'}, age: 33, description:'really silly description'}, | ||
{name: {lastname: 'Leponge', firstname: 'Bob'}, age: 22, description:'really silly description'}, | ||
{name: {lastname: 'Faivre', firstname: 'Blandine'}, age: 44, description:'really silly description'}, | ||
{name: null, age: 33, description:'really silly description'} | ||
]; | ||
var template = '<table st-table="rowCollection">' + | ||
'<thead>' + | ||
'<tr>' + | ||
'<th><input st-search="name.lastname" /></th>' + | ||
'<th><input st-search="name.$" /></th>' + | ||
'<th>age</th>' + | ||
'</tr>' + | ||
'</thead>' + | ||
'<tbody>' + | ||
'<tr class="test-filtered" ng-repeat="row in rowCollection">' + | ||
'<td>{{row.name.lastname}}</td>' + | ||
'<td>{{row.name.firstname}}</td>' + | ||
'<td>{{row.age}}</td>' + | ||
'</tr>' + | ||
'</tbody>' + | ||
'</table>'; | ||
element = $compile(template)(scope); | ||
scope.$apply(); | ||
})); | ||
it('should keep only items which matches', inject(function ($timeout) { | ||
var ths = element.find('th'); | ||
var trs; | ||
var input = angular.element(ths[0].children[0]); | ||
input[0].value = 're'; | ||
input.triggerHandler('input'); | ||
trs = element.find('tr.test-filtered'); | ||
expect(trs.length).toBe(6); | ||
$timeout.flush(); | ||
trs = element.find('tr.test-filtered'); | ||
expect(trs.length).toBe(3); | ||
expect(trToModel(trs)).toEqual([ | ||
{name: 'Renard', firstname: 'Laurent', age: 66}, | ||
{name: 'Renard', firstname: 'Olivier', age: 33}, | ||
{name: 'Faivre', firstname: 'Blandine', age: 44} | ||
]); | ||
})); | ||
it('should search globally within the name object', inject(function ($timeout) { | ||
var ths = element.find('th'); | ||
var input = angular.element(ths[1].children[0]); | ||
input[0].value = 're'; | ||
input.triggerHandler('input'); | ||
$timeout.flush(); | ||
var trs = element.find('tr.test-filtered'); | ||
expect(trs.length).toBe(4); | ||
expect(trToModel(trs)).toEqual([ | ||
{name: 'Renard', firstname: 'Laurent', age: 66}, | ||
{name: 'Francoise', firstname: 'Frere', age: 99}, | ||
{name: 'Renard', firstname: 'Olivier', age: 33}, | ||
{name: 'Faivre', firstname: 'Blandine', age: 44} | ||
]); | ||
})); | ||
it('should be able to reset deep paths', inject(function ($timeout) { | ||
var ths = element.find('th'); | ||
var input = angular.element(ths[0].children[0]); | ||
input[0].value = 're'; | ||
input.triggerHandler('input'); | ||
$timeout.flush(); | ||
input[0].value = ''; | ||
input.triggerHandler('input'); | ||
$timeout.flush(); | ||
trs = element.find('tr.test-filtered'); | ||
expect(trs.length).toBe(6); | ||
})); | ||
}); | ||
}); |
@@ -40,4 +40,6 @@ describe('stSort Directive', function () { | ||
var oldDescentClass = stConfig.sort.descentClass; | ||
var oldSkipNatural = stConfig.sort.skipNatural; | ||
stConfig.sort.ascentClass = 'custom-ascent'; | ||
stConfig.sort.descentClass = 'custom-descent'; | ||
stConfig.sort.skipNatural = true; | ||
@@ -85,2 +87,3 @@ rootScope = $rootScope; | ||
stConfig.sort.descentClass = oldDescentClass; | ||
stConfig.sort.skipNatural = oldSkipNatural; | ||
})); | ||
@@ -94,2 +97,22 @@ | ||
}); | ||
it('should skip natural order', function() { | ||
var ths = element.find('th'); | ||
var th1 = angular.element(ths[1]); | ||
th1.triggerHandler('click'); | ||
th1.triggerHandler('click'); | ||
th1.triggerHandler('click'); | ||
scope.$apply(); | ||
var actual = trToModel(element.find('tr.test-row')); | ||
expect(hasClass(ths[1], 'custom-ascent')).toBe(true); | ||
expect(hasClass(ths[1], 'custom-descent')).toBe(false); | ||
expect(actual).toEqual([ | ||
{name: 'Faivre', firstname: 'Blandine', age: 44}, | ||
{name: 'Leponge', firstname: 'Bob', age: 22}, | ||
{name: 'Francoise', firstname: 'Frere', age: 99}, | ||
{name: 'Renard', firstname: 'Laurent', age: 66}, | ||
{name: 'Renard', firstname: 'Olivier', age: 33} | ||
]); | ||
}); | ||
}); | ||
@@ -393,2 +416,2 @@ | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135354
2451