|
390 | 390 | .directive('mdtTable', mdtTableDirective); |
391 | 391 | }()); |
392 | 392 |
|
| 393 | +(function(){ |
| 394 | + 'use strict'; |
| 395 | + |
| 396 | + EditRowFeature.$inject = ['$mdDialog']; |
| 397 | + function EditRowFeature($mdDialog){ |
| 398 | + |
| 399 | + var service = this; |
| 400 | + |
| 401 | + service.addRequiredFunctions = function($scope, ctrl){ |
| 402 | + |
| 403 | + $scope.saveRow = function(rowData){ |
| 404 | + var rawRowData = ctrl.dataStorage.getSavedRowData(rowData); |
| 405 | + |
| 406 | + $scope.saveRowCallback({row: rawRowData}); |
| 407 | + }; |
| 408 | + |
| 409 | + $scope.showEditDialog = function(ev, cellData, rowData){ |
| 410 | + var rect = ev.currentTarget.closest('td').getBoundingClientRect(); |
| 411 | + var position = { |
| 412 | + top: rect.top, |
| 413 | + left: rect.left |
| 414 | + }; |
| 415 | + |
| 416 | + var ops = { |
| 417 | + controller: 'InlineEditModalCtrl', |
| 418 | + targetEvent: ev, |
| 419 | + clickOutsideToClose: true, |
| 420 | + escapeToClose: true, |
| 421 | + focusOnOpen: false, |
| 422 | + locals: { |
| 423 | + position: position, |
| 424 | + cellData: JSON.parse(JSON.stringify(cellData)), |
| 425 | + mdtTranslations: $scope.mdtTranslations |
| 426 | + } |
| 427 | + }; |
| 428 | + |
| 429 | + if(cellData.attributes.editableField === 'smallEditDialog'){ |
| 430 | + ops.templateUrl = '/main/templates/smallEditDialog.html'; |
| 431 | + }else{ |
| 432 | + ops.templateUrl = '/main/templates/largeEditDialog.html'; |
| 433 | + } |
| 434 | + |
| 435 | + var that = this; |
| 436 | + $mdDialog.show(ops).then(function(cellValue){ |
| 437 | + cellData.value = cellValue; |
| 438 | + |
| 439 | + that.saveRow(rowData); |
| 440 | + }); |
| 441 | + }; |
| 442 | + } |
| 443 | + } |
| 444 | + |
| 445 | + angular |
| 446 | + .module('mdDataTable') |
| 447 | + .service('EditRowFeature', EditRowFeature); |
| 448 | +}()); |
| 449 | +(function(){ |
| 450 | + 'use strict'; |
| 451 | + |
| 452 | + PaginationFeature.$inject = ['mdtPaginationHelperFactory', 'mdtAjaxPaginationHelperFactory']; |
| 453 | + function PaginationFeature(mdtPaginationHelperFactory, mdtAjaxPaginationHelperFactory){ |
| 454 | + var service = this; |
| 455 | + |
| 456 | + service.initFeature = initFeature; |
| 457 | + service.startFeature = startFeature; |
| 458 | + |
| 459 | + function initFeature(scope, ctrl){ |
| 460 | + if(!scope.mdtRowPaginator){ |
| 461 | + ctrl.mdtPaginationHelper = scope.mdtPaginationHelper = mdtPaginationHelperFactory |
| 462 | + .getInstance(ctrl.dataStorage, scope.paginatedRows, scope.mdtRow); |
| 463 | + }else{ |
| 464 | + ctrl.mdtPaginationHelper = scope.mdtPaginationHelper = mdtAjaxPaginationHelperFactory.getInstance({ |
| 465 | + dataStorage: ctrl.dataStorage, |
| 466 | + paginationSetting: scope.paginatedRows, |
| 467 | + mdtRowOptions: scope.mdtRow, |
| 468 | + mdtRowPaginatorFunction: scope.mdtRowPaginator, |
| 469 | + mdtRowPaginatorErrorMessage: scope.mdtRowPaginatorErrorMessage, |
| 470 | + mdtRowPaginatorNoResultsMessage: scope.mdtRowPaginatorNoResultsMessage, |
| 471 | + mdtTriggerRequest: scope.mdtTriggerRequest |
| 472 | + }); |
| 473 | + } |
| 474 | + |
| 475 | + scope.isPaginationEnabled = function(){ |
| 476 | + if(scope.paginatedRows === true || |
| 477 | + (scope.paginatedRows && scope.paginatedRows.hasOwnProperty('isEnabled') && scope.paginatedRows.isEnabled === true)){ |
| 478 | + return true; |
| 479 | + } |
| 480 | + |
| 481 | + return false; |
| 482 | + }; |
| 483 | + |
| 484 | + ctrl.paginationFeature = { |
| 485 | + startPaginationFeature: function() { |
| 486 | + if (scope.mdtRowPaginator) { |
| 487 | + scope.mdtPaginationHelper.fetchPage(1); |
| 488 | + } |
| 489 | + } |
| 490 | + }; |
| 491 | + } |
| 492 | + |
| 493 | + function startFeature(ctrl){ |
| 494 | + ctrl.paginationFeature.startPaginationFeature(); |
| 495 | + } |
| 496 | + } |
| 497 | + |
| 498 | + angular |
| 499 | + .module('mdDataTable') |
| 500 | + .service('PaginationFeature', PaginationFeature); |
| 501 | +}()); |
| 502 | +(function(){ |
| 503 | + 'use strict'; |
| 504 | + |
| 505 | + function SelectableRowsFeatureFactory(){ |
| 506 | + |
| 507 | + function SelectableRowsFeature(params){ |
| 508 | + this.$scope = params.$scope; |
| 509 | + this.ctrl = params.ctrl; |
| 510 | + |
| 511 | + this.$scope.onCheckboxChange = _.bind(this.onCheckboxChange, this); |
| 512 | + } |
| 513 | + |
| 514 | + SelectableRowsFeature.prototype.onCheckboxChange = function(){ |
| 515 | + var that = this; |
| 516 | + // we need to push it to the event loop to make it happen last |
| 517 | + // (e.g.: all the elements can be selected before we call the callback) |
| 518 | + setTimeout(function(){ |
| 519 | + that.$scope.selectedRowCallback({ |
| 520 | + rows: that.ctrl.dataStorage.getSelectedRows() |
| 521 | + }); |
| 522 | + },0); |
| 523 | + }; |
| 524 | + |
| 525 | + return { |
| 526 | + getInstance: function(params){ |
| 527 | + return new SelectableRowsFeature(params); |
| 528 | + } |
| 529 | + }; |
| 530 | + } |
| 531 | + |
| 532 | + angular |
| 533 | + .module('mdDataTable') |
| 534 | + .service('SelectableRowsFeature', SelectableRowsFeatureFactory); |
| 535 | +}()); |
393 | 536 | (function(){ |
394 | 537 | 'use strict'; |
395 | 538 |
|
|
863 | 1006 | (function(){ |
864 | 1007 | 'use strict'; |
865 | 1008 |
|
866 | | - EditRowFeature.$inject = ['$mdDialog']; |
867 | | - function EditRowFeature($mdDialog){ |
868 | | - |
869 | | - var service = this; |
870 | | - |
871 | | - service.addRequiredFunctions = function($scope, ctrl){ |
872 | | - |
873 | | - $scope.saveRow = function(rowData){ |
874 | | - var rawRowData = ctrl.dataStorage.getSavedRowData(rowData); |
875 | | - |
876 | | - $scope.saveRowCallback({row: rawRowData}); |
877 | | - }; |
878 | | - |
879 | | - $scope.showEditDialog = function(ev, cellData, rowData){ |
880 | | - var rect = ev.currentTarget.closest('td').getBoundingClientRect(); |
881 | | - var position = { |
882 | | - top: rect.top, |
883 | | - left: rect.left |
884 | | - }; |
885 | | - |
886 | | - var ops = { |
887 | | - controller: 'InlineEditModalCtrl', |
888 | | - targetEvent: ev, |
889 | | - clickOutsideToClose: true, |
890 | | - escapeToClose: true, |
891 | | - focusOnOpen: false, |
892 | | - locals: { |
893 | | - position: position, |
894 | | - cellData: JSON.parse(JSON.stringify(cellData)), |
895 | | - mdtTranslations: $scope.mdtTranslations |
896 | | - } |
897 | | - }; |
898 | | - |
899 | | - if(cellData.attributes.editableField === 'smallEditDialog'){ |
900 | | - ops.templateUrl = '/main/templates/smallEditDialog.html'; |
901 | | - }else{ |
902 | | - ops.templateUrl = '/main/templates/largeEditDialog.html'; |
903 | | - } |
904 | | - |
905 | | - var that = this; |
906 | | - $mdDialog.show(ops).then(function(cellValue){ |
907 | | - cellData.value = cellValue; |
908 | | - |
909 | | - that.saveRow(rowData); |
910 | | - }); |
911 | | - }; |
912 | | - } |
913 | | - } |
914 | | - |
915 | | - angular |
916 | | - .module('mdDataTable') |
917 | | - .service('EditRowFeature', EditRowFeature); |
918 | | -}()); |
919 | | -(function(){ |
920 | | - 'use strict'; |
921 | | - |
922 | | - PaginationFeature.$inject = ['mdtPaginationHelperFactory', 'mdtAjaxPaginationHelperFactory']; |
923 | | - function PaginationFeature(mdtPaginationHelperFactory, mdtAjaxPaginationHelperFactory){ |
924 | | - var service = this; |
925 | | - |
926 | | - service.initFeature = initFeature; |
927 | | - service.startFeature = startFeature; |
928 | | - |
929 | | - function initFeature(scope, ctrl){ |
930 | | - if(!scope.mdtRowPaginator){ |
931 | | - ctrl.mdtPaginationHelper = scope.mdtPaginationHelper = mdtPaginationHelperFactory |
932 | | - .getInstance(ctrl.dataStorage, scope.paginatedRows, scope.mdtRow); |
933 | | - }else{ |
934 | | - ctrl.mdtPaginationHelper = scope.mdtPaginationHelper = mdtAjaxPaginationHelperFactory.getInstance({ |
935 | | - dataStorage: ctrl.dataStorage, |
936 | | - paginationSetting: scope.paginatedRows, |
937 | | - mdtRowOptions: scope.mdtRow, |
938 | | - mdtRowPaginatorFunction: scope.mdtRowPaginator, |
939 | | - mdtRowPaginatorErrorMessage: scope.mdtRowPaginatorErrorMessage, |
940 | | - mdtRowPaginatorNoResultsMessage: scope.mdtRowPaginatorNoResultsMessage, |
941 | | - mdtTriggerRequest: scope.mdtTriggerRequest |
942 | | - }); |
943 | | - } |
944 | | - |
945 | | - scope.isPaginationEnabled = function(){ |
946 | | - if(scope.paginatedRows === true || |
947 | | - (scope.paginatedRows && scope.paginatedRows.hasOwnProperty('isEnabled') && scope.paginatedRows.isEnabled === true)){ |
948 | | - return true; |
949 | | - } |
950 | | - |
951 | | - return false; |
952 | | - }; |
953 | | - |
954 | | - ctrl.paginationFeature = { |
955 | | - startPaginationFeature: function() { |
956 | | - if (scope.mdtRowPaginator) { |
957 | | - scope.mdtPaginationHelper.fetchPage(1); |
958 | | - } |
959 | | - } |
960 | | - }; |
961 | | - } |
962 | | - |
963 | | - function startFeature(ctrl){ |
964 | | - ctrl.paginationFeature.startPaginationFeature(); |
965 | | - } |
966 | | - } |
967 | | - |
968 | | - angular |
969 | | - .module('mdDataTable') |
970 | | - .service('PaginationFeature', PaginationFeature); |
971 | | -}()); |
972 | | -(function(){ |
973 | | - 'use strict'; |
974 | | - |
975 | | - function SelectableRowsFeatureFactory(){ |
976 | | - |
977 | | - function SelectableRowsFeature(params){ |
978 | | - this.$scope = params.$scope; |
979 | | - this.ctrl = params.ctrl; |
980 | | - |
981 | | - this.$scope.onCheckboxChange = _.bind(this.onCheckboxChange, this); |
982 | | - } |
983 | | - |
984 | | - SelectableRowsFeature.prototype.onCheckboxChange = function(){ |
985 | | - var that = this; |
986 | | - // we need to push it to the event loop to make it happen last |
987 | | - // (e.g.: all the elements can be selected before we call the callback) |
988 | | - setTimeout(function(){ |
989 | | - that.$scope.selectedRowCallback({ |
990 | | - rows: that.ctrl.dataStorage.getSelectedRows() |
991 | | - }); |
992 | | - },0); |
993 | | - }; |
994 | | - |
995 | | - return { |
996 | | - getInstance: function(params){ |
997 | | - return new SelectableRowsFeature(params); |
998 | | - } |
999 | | - }; |
1000 | | - } |
1001 | | - |
1002 | | - angular |
1003 | | - .module('mdDataTable') |
1004 | | - .service('SelectableRowsFeature', SelectableRowsFeatureFactory); |
1005 | | -}()); |
1006 | | -(function(){ |
1007 | | - 'use strict'; |
1008 | | - |
1009 | 1009 | ColumnAlignmentHelper.$inject = ['ColumnOptionProvider']; |
1010 | 1010 | function ColumnAlignmentHelper(ColumnOptionProvider){ |
1011 | 1011 | var service = this; |
|
0 commit comments