Best JavaScript code snippet using testcafe
contractSearchController.js
Source:contractSearchController.js
1/* Modal Controller */2MetronicApp.controller('contractSearchController', [3 '$scope',4 'dataTree',5 'caller',6 'modalInstance1',7 'gridOptions',8 'popupId',9 'isMultiSelect',10 'CommonService',11 'htmlCommonService',12 'SearchService',13 'PopupConst',14 'RestEndpoint',15 '$localStorage',16 '$rootScope',17 'cntContractService',18 function($scope, dataTree, caller, modalInstance1,gridOptions, popupId, isMultiSelect,19 CommonService,htmlCommonService, SearchService, PopupConst, RestEndpoint,20 $localStorage, $rootScope, cntContractService) {21 22 $rootScope.flag=false;23 24 $scope.modalInstance = modalInstance1;25 $scope.popupId = popupId;26 $scope.caller = caller;27 $scope.cancel = cancel;28 $scope.save = save;29 $scope.isMultiSelect = isMultiSelect;30 function fillTable(result){31 $scope.gridOptions = kendoConfig.getGridOptions({32 autoBind: true,33 resizable: true,34 dataSource: result,35 noRecords: true,36 columnMenu:false,37 scrollable:false,38 messages: {39 noRecords : "Không có kết quả hiá»n thá»"40 },41 pageSize:10,42 pageable: {43 refresh: false,44 pageSize:10,45 pageSizes: [10, 15, 20, 25],46 messages: {47 display: "{0}-{1} của {2} kết quả",48 itemsPerPage: "kết quả/trang",49 empty: "Không có kết quả hiá»n thá»"50 }51 },52 dataBound: function (e) {53 var grid = $("#gridView").data("kendoGrid");54 grid.tbody.find("tr").dblclick(function (e) {55 var dataItem = grid.dataItem(this);56 $('#'+dataItem.code).click();57 });58 },59 columns:[{60 title: "TT",61 field: "#",62 width:'6%',63 template: dataItem => $("#gridView").data("kendoGrid").dataSource.indexOf(dataItem) + 1 ,64 headerAttributes: {65 style: "text-align:center;"66 },67 attributes: {68 style: "text-align:center;"69 },70 }, 71 {72 title: "Mã hợp Äá»ng",73 field: "code",74 headerAttributes: {75 style: "text-align:center;"76 },77 attributes: {78 style: "text-align:left;"79 },80 }, {81 title: "Tên hợp Äá»ng",82 field: "name",83 headerAttributes: {84 style: "text-align:center;"85 },86 attributes: {87 style: "text-align:left;"88 },89 }, {90 title: "Giá trá»",91 field: "price",92 headerAttributes: {93 style: "text-align:center;"94 },95 attributes: {96 style: "text-align:left;"97 },98 },{99 title: "Chá»n",100 template: 101 '<div class="text-center "> ' +102 ' <a type="button" class=" icon_table" uib-tooltip="Chá»n" translate>'+103 ' <i id="#=code#" ng-click=save(dataItem) class="fa fa-check color-green" aria-hidden="true"></i> '+104 ' </a>'105 +'</div>', 106 width: "15%",107 field:"stt"108 }109 ]110 });111 112 }113 $( document ).ready(function() {114 var obj={};115 if($('#treeviewUnits')){116 cntContractService.doSearch(obj).then(function(result){117 var data=genData(result.plain(),null);118 fillTable(result.plain());119 });120 }121 });122 123 function genData(items, parent) {124 var itemArr = [];125 for (var i = 0; i < items.length; i++) {126 if (items[i].parentId === parent) {127 var row = items[i];128 row.id = items[i].id;129 row.text = items[i].text;130 row.children = genData(items, items[i].id);131 itemArr.push(row);132 }133 }134 return itemArr;135 }136 137 $scope.onRowChange=onRowChange;138 139 function onRowChange(dataItem){140 $scope.dataItem=dataItem;141 }142 143 function cancel() {144 htmlCommonService.dismissPopup();145 }146 function save(dataItem) {147 if(dataItem){148 caller.onSaveContract(dataItem);149 htmlCommonService.dismissPopup();150 } else{151 if ($scope.dataItem) {152 caller.onSave($scope.dataItem, $scope.popupId);153 htmlCommonService.dismissPopup();154 } else {155 if($scope.parent){156 caller.onSave($scope.parent);157 htmlCommonService.dismissPopup();158 } else{159 if(confirm('ChÆ°a chá»n bản ghi nà o!')){160 htmlCommonService.dismissPopup();161 }162 }163 }164 }165 166 }167 $scope.filterTree=filterTree168// $("#filterText").keyup(function (e) {169 function filterTree(keyEvent){170 filter($scope.treeView.dataSource, keyEvent.target.value.toLowerCase());171 }172 173 function filter(dataSource, query) {174 var hasVisibleChildren = false;175 var data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();176 for (var i = 0; i < data.length; i++) {177 var item = data[i];178 var text = item.text.toLowerCase();179 var itemVisible =180 query === true // parent already matches181 || query === "" // query is empty182 || text.indexOf(query) >= 0; // item text matches query183 var anyVisibleChildren = filter(item.children, itemVisible || query); // pass true if parent matches184 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;185 item.hidden = !itemVisible && !anyVisibleChildren;186 }187 if (data) {188 // re-apply filter on children189 dataSource.filter({ field: "hidden", operator: "neq", value: true });190 }191 return hasVisibleChildren;192 }193 $scope.doSearch= function(){194 // $("#deptCode").val($("#deptCode").val().trim());195 // $("#deptName").val($("#deptName").val().trim());196 trimSpace();197 if($scope.parent){198 $scope.searchGrid.id=$scope.parent.id;199 }200 var obj = {};201 if(!! $scope.searchGrid)202 obj = {203 keySearch : $scope.searchGrid.code,204 }205 cntContractService.doSearch(obj).then(function(result){206 var grid = $scope.gridView;207 grid.dataSource.data(result.plain().data);208 fillTable(result.plain());209 grid.refresh();210 });211 }212 213 214 ...
constructTypeSearchController.js
Source:constructTypeSearchController.js
1/* Modal Controller */2MetronicApp.controller('constructTypeSearchController', [3 '$scope',4 'dataTree',5 'caller',6 'modalInstance1',7 'gridOptions',8 'popupId',9 'isMultiSelect',10 'CommonService',11 'htmlCommonService',12 'SearchService',13 'PopupConst',14 'RestEndpoint',15 '$localStorage',16 '$rootScope',17 'popupSearchService',18 function($scope, dataTree, caller, modalInstance1,gridOptions, popupId, isMultiSelect,19 CommonService,htmlCommonService, SearchService, PopupConst, RestEndpoint,20 $localStorage, $rootScope, popupSearchService) {21 22 $rootScope.flag=false;23 24 $scope.modalInstance = modalInstance1;25 $scope.popupId = popupId;26 $scope.caller = caller;27 $scope.cancel = cancel;28 $scope.save = save;29 $scope.isMultiSelect = isMultiSelect;30 function fillTable(result){31 $scope.gridOptions = kendoConfig.getGridOptions({32 autoBind: true,33 resizable: true,34 dataSource: result,35 noRecords: true,36 columnMenu:false,37 scrollable:false,38 messages: {39 noRecords : "Không có kết quả hiá»n thá»"40 },41 pageSize:10,42 pageable: {43 refresh: false,44 pageSize:10,45 pageSizes: [10, 15, 20, 25],46 messages: {47 display: "{0}-{1} của {2} kết quả",48 itemsPerPage: "kết quả/trang",49 empty: "Không có kết quả hiá»n thá»"50 }51 },52 dataBound: function (e) {53 var grid = $("#gridView").data("kendoGrid");54 grid.tbody.find("tr").dblclick(function (e) {55 var dataItem = grid.dataItem(this);56 $('#'+dataItem.code).click();57 });58 },59 columns:[{60 title: "TT",61 field: "#",62 width:'10%',63 template: dataItem => $("#gridView").data("kendoGrid").dataSource.indexOf(dataItem) + 1 ,64 headerAttributes: {65 style: "text-align:center;"66 },67 attributes: {68 style: "text-align:center;"69 },70 }, 71 {72 title: "Mã loại công trình",73 field: "code",74 headerAttributes: {75 style: "text-align:center;"76 },77 attributes: {78 style: "text-align:left;"79 },80 }, {81 title: "Tên loại công trình",82 field: "name",83 headerAttributes: {84 style: "text-align:center;"85 },86 attributes: {87 style: "text-align:left;"88 },89 },{90 title: "Chá»n",91 template: 92 '<div class="text-center "> ' +93 ' <a type="button" class=" icon_table" uib-tooltip="Chá»n" translate>'+94 ' <i id="#=code#" ng-click=save(dataItem) class="fa fa-check color-green" aria-hidden="true"></i> '+95 ' </a>'96 +'</div>', 97 width: "15%",98 field:"stt"99 }100 ]101 });102 103 }104 $( document ).ready(function() {105 var obj={};106 if($('#treeviewUnits')){107 popupSearchService.getAllConstructionType(obj).then(function(result){108 var data=genData(result.plain(),null);109 fillTable(result.plain());110 });111 }112 });113 114 function genData(items, parent) {115 var itemArr = [];116 for (var i = 0; i < items.length; i++) {117 if (items[i].parentId === parent) {118 var row = items[i];119 row.id = items[i].id;120 row.text = items[i].text;121 row.children = genData(items, items[i].id);122 itemArr.push(row);123 }124 }125 return itemArr;126 }127 128 $scope.onRowChange=onRowChange;129 130 function onRowChange(dataItem){131 $scope.dataItem=dataItem;132 }133 134 function cancel() {135 htmlCommonService.dismissPopup();136 // caller.cancel();137 }138 function save(dataItem) {139 if(dataItem){140 caller.onSaveConstructTypeId(dataItem);141 htmlCommonService.dismissPopup();142 } else{143 if ($scope.dataItem) {144 caller.onSave($scope.dataItem, $scope.popupId);145 htmlCommonService.dismissPopup();146 } else {147 if($scope.parent){148 caller.onSave($scope.parent);149 htmlCommonService.dismissPopup();150 } else{151 if(confirm('ChÆ°a chá»n bản ghi nà o!')){152 htmlCommonService.dismissPopup();153 }154 }155 }156 }157 158 }159 $scope.filterTree=filterTree160// $("#filterText").keyup(function (e) {161 function filterTree(keyEvent){162 filter($scope.treeView.dataSource, keyEvent.target.value.toLowerCase());163 }164 165 function filter(dataSource, query) {166 var hasVisibleChildren = false;167 var data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();168 for (var i = 0; i < data.length; i++) {169 var item = data[i];170 var text = item.text.toLowerCase();171 var itemVisible =172 query === true // parent already matches173 || query === "" // query is empty174 || text.indexOf(query) >= 0; // item text matches query175 var anyVisibleChildren = filter(item.children, itemVisible || query); // pass true if parent matches176 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;177 item.hidden = !itemVisible && !anyVisibleChildren;178 }179 if (data) {180 // re-apply filter on children181 dataSource.filter({ field: "hidden", operator: "neq", value: true });182 }183 return hasVisibleChildren;184 }185 $scope.doSearch= function(){186 // $("#deptCode").val($("#deptCode").val().trim());187 // $("#deptName").val($("#deptName").val().trim());188 trimSpace();189 if($scope.parent){190 $scope.searchGrid.id=$scope.parent.id;191 }192 var obj = {};193 if(!! $scope.searchGrid)194 obj = {195 keySearch : $scope.searchGrid.code,196 }197 popupSearchService.getAllConstructionType(obj).then(function(result){198 var grid = $scope.gridView;199 grid.dataSource.data(result.plain().data);200 fillTable(result.plain());201 grid.refresh();202 });203 }204 205 206 ...
partnerSearchController.js
Source:partnerSearchController.js
1/* Modal Controller */2MetronicApp.controller('partnerSearchController', [3 '$scope',4 'dataTree',5 'caller',6 'modalInstance1',7 'gridOptions',8 'popupId',9 'isMultiSelect',10 'CommonService',11 'htmlCommonService',12 'SearchService',13 'PopupConst',14 'RestEndpoint',15 '$localStorage',16 '$rootScope',17 'popupSearchService',18 function($scope, dataTree, caller, modalInstance1,gridOptions, popupId, isMultiSelect,19 CommonService,htmlCommonService, SearchService, PopupConst, RestEndpoint,20 $localStorage, $rootScope, popupSearchService) {21 22 $rootScope.flag=false;23 24 $scope.modalInstance = modalInstance1;25 $scope.popupId = popupId;26 $scope.caller = caller;27 $scope.cancel = cancel;28 $scope.save = save;29 $scope.isMultiSelect = isMultiSelect;30 function fillTable(result){31 $scope.gridOptions = kendoConfig.getGridOptions({32 autoBind: true,33 resizable: true,34 dataSource: result,35 noRecords: true,36 columnMenu:false,37 scrollable:false,38 messages: {39 noRecords : "Không có kết quả hiá»n thá»"40 },41 pageSize:10,42 pageable: {43 refresh: false,44 pageSize:10,45 pageSizes: [10, 15, 20, 25],46 messages: {47 display: "{0}-{1} của {2} kết quả",48 itemsPerPage: "kết quả/trang",49 empty: "Không có kết quả hiá»n thá»"50 }51 },52 dataBound: function (e) {53 var grid = $("#gridView").data("kendoGrid");54 grid.tbody.find("tr").dblclick(function (e) {55 var dataItem = grid.dataItem(this);56 $('#'+dataItem.code).click();57 });58 },59 columns:[{60 title: "TT",61 field: "#",62 width:'10%',63 template: dataItem => $("#gridView").data("kendoGrid").dataSource.indexOf(dataItem) + 1 ,64 headerAttributes: {65 style: "text-align:center;"66 },67 attributes: {68 style: "text-align:center;"69 },70 }, 71 {72 title: "Mã Äá»i tác",73 field: "code",74 headerAttributes: {75 style: "text-align:center;"76 },77 attributes: {78 style: "text-align:left;"79 },80 }, {81 title: "Tên Äá»i tác",82 field: "name",83 headerAttributes: {84 style: "text-align:center;"85 },86 attributes: {87 style: "text-align:left;"88 },89 },{90 title: "Chá»n",91 template: 92 '<div class="text-center "> ' +93 ' <a type="button" class=" icon_table" uib-tooltip="Chá»n" translate>'+94 ' <i id="#=code#" ng-click=save(dataItem) class="fa fa-check color-green" aria-hidden="true"></i> '+95 ' </a>'96 +'</div>', 97 width: "15%",98 field:"stt"99 }100 ]101 });102 103 }104 $( document ).ready(function() {105 var obj={status:1};106 if($('#treeviewUnits')){107 popupSearchService.getAllPartner(obj).then(function(result){108 var data=genData(result.plain(),null);109 fillTable(result.plain());110 });111 }112 });113 114 function genData(items, parent) {115 var itemArr = [];116 for (var i = 0; i < items.length; i++) {117 if (items[i].parentId === parent) {118 var row = items[i];119 row.id = items[i].id;120 row.text = items[i].text;121 row.children = genData(items, items[i].id);122 itemArr.push(row);123 }124 }125 return itemArr;126 }127 128 $scope.onRowChange=onRowChange;129 130 function onRowChange(dataItem){131 $scope.dataItem=dataItem;132 }133 134 function cancel() {135 htmlCommonService.dismissPopup();136 }137 function save(dataItem) {138 if(dataItem){139 caller.onSavePartnerId(dataItem);140 htmlCommonService.dismissPopup();141 } else{142 if ($scope.dataItem) {143 caller.onSavePartnerId($scope.dataItem, $scope.popupId);144 htmlCommonService.dismissPopup();145 } else {146 if($scope.parent){147 caller.onSavePartnerId($scope.parent);148 htmlCommonService.dismissPopup();149 } else{150 if(confirm('ChÆ°a chá»n bản ghi nà o!')){151 htmlCommonService.dismissPopup();152 }153 }154 }155 }156 157 }158 $scope.filterTree=filterTree159// $("#filterText").keyup(function (e) {160 function filterTree(keyEvent){161 filter($scope.treeView.dataSource, keyEvent.target.value.toLowerCase());162 }163 164 function filter(dataSource, query) {165 var hasVisibleChildren = false;166 var data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();167 for (var i = 0; i < data.length; i++) {168 var item = data[i];169 var text = item.text.toLowerCase();170 var itemVisible =171 query === true // parent already matches172 || query === "" // query is empty173 || text.indexOf(query) >= 0; // item text matches query174 var anyVisibleChildren = filter(item.children, itemVisible || query); // pass true if parent matches175 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;176 item.hidden = !itemVisible && !anyVisibleChildren;177 }178 if (data) {179 // re-apply filter on children180 dataSource.filter({ field: "hidden", operator: "neq", value: true });181 }182 return hasVisibleChildren;183 }184 $scope.doSearch= function(){185 // $("#deptCode").val($("#deptCode").val().trim());186 // $("#deptName").val($("#deptName").val().trim());187 trimSpace();188 if($scope.parent){189 $scope.searchGrid.id=$scope.parent.id;190 }191 var obj = {};192 if(!! $scope.searchGrid)193 obj = {194 keySearch : $scope.searchGrid.code,195 }196 popupSearchService.getAllSysGroup(obj).then(function(result){197 var grid = $scope.gridView;198 grid.dataSource.data(result.plain().data);199 fillTable(result.plain());200 grid.refresh();201 });202 }203 204 205 ...
popupUnitSearchController.js
Source:popupUnitSearchController.js
1/* Modal Controller */2MetronicApp.controller('popupUnitSearchController', [3 '$scope',4 'dataTree',5 'caller',6 'modalInstance1',7 'gridOptions',8 'popupId',9 'isMultiSelect',10 'CommonService',11 'SearchService',12 'PopupConst',13 'RestEndpoint',14 '$localStorage',15 '$rootScope',16 'goodsService',17 function($scope, dataTree, caller, modalInstance1,gridOptions, popupId, isMultiSelect,18 CommonService, SearchService, PopupConst, RestEndpoint,19 $localStorage, $rootScope, goodsService) {20 21 $rootScope.flag=false;22 23 $scope.modalInstance = modalInstance1;24 $scope.popupId = popupId;25 $scope.caller = caller;26 $scope.cancel = cancel;27 $scope.save = save;28 $scope.isMultiSelect = isMultiSelect;29 function fillTable(result){30 $scope.gridOptions = kendoConfig.getGridOptions({31 autoBind: true,32 resizable: true,33 dataSource: result,34 noRecords: true,35 columnMenu:false,36 scrollable:false,37 messages: {38 noRecords : "Không có kết quả hiá»n thá»"39 },40 pageSize:10,41 pageable: {42 refresh: false,43 pageSize:10,44 pageSizes: [10, 15, 20, 25],45 messages: {46 display: "{0}-{1} của {2} kết quả",47 itemsPerPage: "kết quả/trang",48 empty: "Không có kết quả hiá»n thá»"49 }50 },51 dataBound: function (e) {52 var grid = $("#gridView").data("kendoGrid");53 grid.tbody.find("tr").dblclick(function (e) {54 var dataItem = grid.dataItem(this);55 $('#'+dataItem.code).click();56 });57 },58 columns:[{59 title: "TT",60 field: "#",61 width:'10%',62 template: dataItem => $("#gridView").data("kendoGrid").dataSource.indexOf(dataItem) + 1 ,63 headerAttributes: {64 style: "text-align:center;"65 },66 attributes: {67 style: "text-align:center;"68 },69 }, 70 {71 title: "Mã ÄÆ¡n vá»",72 field: "code",73 headerAttributes: {74 style: "text-align:center;"75 },76 attributes: {77 style: "text-align:left;"78 },79 }, {80 title: "Tên ÄÆ¡n vá»",81 field: "name",82 headerAttributes: {83 style: "text-align:center;"84 },85 attributes: {86 style: "text-align:left;"87 },88 },{89 title: "Chá»n",90 template: 91 '<div class="text-center "> ' +92 ' <a type="button" class=" icon_table" uib-tooltip="Chá»n" translate>'+93 ' <i id="#=code#" ng-click=save(dataItem) class="fa fa-check color-green" aria-hidden="true"></i> '+94 ' </a>'95 +'</div>', 96 width: "15%",97 field:"stt"98 }99 ]100 });101 102 }103 $( document ).ready(function() {104 var obj={};105 if($('#treeviewUnits')){106 goodsService.getAllUnit(obj).then(function(result){107 var data=genData(result.plain(),null);108 fillTable(result.plain());109 });110 }111 });112 113 function genData(items, parent) {114 var itemArr = [];115 for (var i = 0; i < items.length; i++) {116 if (items[i].parentId === parent) {117 var row = items[i];118 row.id = items[i].id;119 row.text = items[i].text;120 row.children = genData(items, items[i].id);121 itemArr.push(row);122 }123 }124 return itemArr;125 }126 127 $scope.onRowChange=onRowChange;128 129 function onRowChange(dataItem){130 $scope.dataItem=dataItem;131 }132 133 function cancel() {134 CommonService.dismissPopup1();135 // caller.cancel();136 }137 function save(dataItem) {138 if(dataItem){139 caller.onSave(dataItem);140 CommonService.dismissPopup1();141 } else{142 if ($scope.dataItem) {143 caller.onSave($scope.dataItem, $scope.popupId);144 CommonService.dismissPopup1();145 } else {146 if($scope.parent){147 caller.onSave($scope.parent);148 CommonService.dismissPopup1();149 } else{150 if(confirm('ChÆ°a chá»n bản ghi nà o!')){151 CommonService.dismissPopup1();152 }153 }154 }155 }156 157 }158 $scope.filterTree=filterTree159// $("#filterText").keyup(function (e) {160 function filterTree(keyEvent){161 filter($scope.treeView.dataSource, keyEvent.target.value.toLowerCase());162 }163 164 function filter(dataSource, query) {165 var hasVisibleChildren = false;166 var data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();167 for (var i = 0; i < data.length; i++) {168 var item = data[i];169 var text = item.text.toLowerCase();170 var itemVisible =171 query === true // parent already matches172 || query === "" // query is empty173 || text.indexOf(query) >= 0; // item text matches query174 var anyVisibleChildren = filter(item.children, itemVisible || query); // pass true if parent matches175 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;176 item.hidden = !itemVisible && !anyVisibleChildren;177 }178 if (data) {179 // re-apply filter on children180 dataSource.filter({ field: "hidden", operator: "neq", value: true });181 }182 return hasVisibleChildren;183 }184 $scope.doSearch= function(){185 // $("#deptCode").val($("#deptCode").val().trim());186 // $("#deptName").val($("#deptName").val().trim());187 trimSpace();188 if($scope.parent){189 $scope.searchGrid.id=$scope.parent.id;190 }191 var obj = {};192 if(!! $scope.searchGrid)193 obj = {194 keySearch : $scope.searchGrid.code,195 }196 goodsService.getAllUnit(obj).then(function(result){197 var grid = $scope.gridView;198 grid.dataSource.data(result.plain().data);199 fillTable(result.plain());200 grid.refresh();201 });202 }203 204 205 ...
popupDepartmentController.js
Source:popupDepartmentController.js
1/* Modal Controller */2MetronicApp.controller('popupDepartmentController', [3 '$scope',4 'dataTree',5 'caller',6 'modalInstance',7 'gridOptions',8 'popupId',9 'isMultiSelect',10 'CommonService',11 'SearchService',12 'PopupConst',13 'RestEndpoint',14 '$localStorage',15 '$rootScope',16 function($scope, dataTree, caller, modalInstance,gridOptions, popupId, isMultiSelect,17 CommonService, SearchService, PopupConst, RestEndpoint,18 $localStorage, $rootScope) {19 20 $rootScope.flag=false;21 22 $scope.modalInstance = modalInstance;23 $scope.popupId = popupId;24 $scope.caller = caller;25 $scope.cancel = cancel;26 $scope.save = save;27 $scope.isMultiSelect = isMultiSelect;28 $scope.gridOptions = gridOptions;29 function genData(items, parent) {30 var itemArr = [];31 for (var i = 0; i < items.length; i++) {32 if (items[i].parentId === parent) {33 var row = items[i];34 row.id = items[i].id;35 row.text = items[i].text;36 row.items = genData(items, items[i].id);37 itemArr.push(row);38 }39 }40 return itemArr;41 }42 $scope.data = new kendo.data.HierarchicalDataSource({ data: genData(dataTree,null) });43 $scope.treeViewOptions = {44 dataSource: $scope.data,45 dataTextField: "text",46 loadOnDemand: false,47 expandAll: true, 48 dataBound: function (e) {49 e.sender.expand(e.node);50 },51 }52 53 54 55 $scope.onChangeTree=onChangeTree;56 function onChangeTree(dataItem){57 var obj={};58 obj.id=dataItem.id59 $scope.parent=dataItem;60 CommonService.getDepartment(obj).then(function(result){61 var grid = $scope.gridView;62 grid.dataSource.data(result.plain());63 if(result.plain().length>0){64 grid.dataSource.page(1);65 }66 grid.refresh();67 });68 }69 70 $scope.onRowChange=onRowChange;71 72 function onRowChange(dataItem){73 $scope.dataItem=dataItem;74 }75 76 function cancel() {77 CommonService.dismissPopup();78 // caller.cancel();79 }80 function save() {81 if ($scope.dataItem) {82 caller.onSave($scope.dataItem, $scope.popupId);83 CommonService.dismissPopup();84 } else {85 if($scope.parent){86 caller.onSave($scope.parent);87 CommonService.dismissPopup();88 } else{89 if(confirm('ChÆ°a chá»n bản ghi nà o!')){90 CommonService.dismissPopup();91 }92 }93 }94 95 96 }97 $scope.filterTree=filterTree98// $("#filterText").keyup(function (e) {99 function filterTree(keyEvent){100 filter($scope.treeView.dataSource, keyEvent.target.value.toLowerCase());101 }102 103 function filter(dataSource, query) {104 var hasVisibleChildren = false;105 var data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();106 for (var i = 0; i < data.length; i++) {107 var item = data[i];108 var text = item.text.toLowerCase();109 var itemVisible =110 query === true // parent already matches111 || query === "" // query is empty112 || text.indexOf(query) >= 0; // item text matches query113 var anyVisibleChildren = filter(item.children, itemVisible || query); // pass true if parent matches114 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;115 item.hidden = !itemVisible && !anyVisibleChildren;116 }117 if (data) {118 // re-apply filter on children119 dataSource.filter({ field: "hidden", operator: "neq", value: true });120 }121 return hasVisibleChildren;122 }123 $scope.doSearch= function(){124 if($scope.parent){125 $scope.searchGrid.id=$scope.parent.id;126 }127 CommonService.getDepartment($scope.searchGrid).then(function(result){128 var grid = $scope.gridView;129 grid.dataSource.data(result.plain());130 if(result.plain().length>0){131 grid.dataSource.page(1);132 }133 grid.refresh();134 });135 }136 ...
dropdowns.js
Source:dropdowns.js
1function onChange(classNameTag) {2 let tooltip = $('#' + classNameTag + 'Wrapper').data('kendoTooltip');3 if (tooltip) {4 let tree = $('input.' + classNameTag).data('kendoDropDownTree');5 tooltip.options.content = tree.text();6 tooltip.refresh();7 }8}9function onFiltering(e) {10 e.preventDefault();11 let query = e instanceof Array && e[0] ? '' : e.filter.value;12 if (query)13 query = query.toLowerCase();14 let dataSource = e.sender.dataSource;15 if (query === '')16 clearDataSource(dataSource);17 filterDataSource(dataSource, query);18 e.sender.trigger('onFiltered');19}20function filterDataSource(dataSource, query) {21 let hasVisibleChildren = false;22 let data = dataSource instanceof kendo.data.HierarchicalDataSource && dataSource.data();23 for (let i = 0; i < data.length; i++) {24 let item = data[i];25 let text = item.text.toLowerCase();26 let itemVisible =27 query === '' || text.indexOf(query) >= 0;28 let anyVisibleChildren = filterDataSource(item.children, query);29 hasVisibleChildren = hasVisibleChildren || anyVisibleChildren || itemVisible;30 item.hidden = (!item.hasChildren && !itemVisible) || (item.hasChildren && !anyVisibleChildren);31 }32 if (data) {33 dataSource.filter({field: 'hidden', operator: 'neq', value: true});34 }35 return hasVisibleChildren;36}37function clearDataSource(dataSource) {38 let data = dataSource._data;39 if (data && data.length > 0) {40 for (let i = 0; i < data.length; i++) {41 data[i].dirty = false;42 data[i].dirtyFields = {};43 data[i].expanded = false;44 if (data[i].hasChildren) {45 for (let j = 0; j < data[i].items.length; j++) {46 data[i].items[j].dirty = false;47 data[i].items[j].dirtyFields = {};48 data[i].items[j].selected = false;49 }50 }51 }52 }53}54function setAutoClose(classNameTag) {55 let checkExist = setInterval(function () {56 let tree = $('input.' + classNameTag).data('kendoDropDownTree');57 if (tree !== undefined) {58 tree.options.autoClose = false;59 tree.treeview.bind('select', e => onSelected(e));60 tree.bind('change', () => onChange(classNameTag));61 tree.bind('filtering', e => onFiltering(e));62 clearInterval(checkExist);63 }64 });65}66function onSelected(e) {67 if (e.sender.dataItem(e.node).hasChildren) {68 e.preventDefault()69 } else {70 e.sender.dropdowntree.close();71 }72}73function clearField(classNameTag) {74 let tree = $('input.' + classNameTag).data('kendoDropDownTree');75 tree.value('');76 tree.filterInput.val('');77 tree._prev = '';78 tree.trigger('change');79 tree.trigger('filtering', [true]);80}81function init(classNameTag, addFunction) {82 $(document).ready(function () {83 $('.add-button-' + classNameTag).on('click', addFunction)84 });85 $(document).ready(function () {86 $('.clear-button-' + classNameTag).on('click', () => clearField(classNameTag));87 });88 setAutoClose(classNameTag);...
Container.js
Source:Container.js
1//BEGIN CMVC 2//*************************************************************************3//4// Workfile: BPCSRVR/ws/code/processwidget/src/WebContent/bpc/bpel/Container.js, BPC.client, WBIX.BPCSRVR, of0947.125// Last update: 09/11/10 07:01:596// SCCS path, id: /family/botp/vc/13/6/9/1/s.77 1.107//8//*************************************************************************9//END CMVC10//BEGIN COPYRIGHT11//*************************************************************************12//13// Licensed Materials - Property of IBM14// 5655-FLW15// Copyright IBM Corporation 2008, 2009. All Rights Reserved.16// US Government Users Restricted Rights- Use, duplication or disclosure17// restricted by GSA ADP Schedule Contract with IBM Corp.18//19//*************************************************************************20//END COPYRIGHT21dojo.provide("bpc.bpel.Container");22dojo.require("bpc.bpel.ProcessNode");23dojo.declare("bpc.bpel.Container", bpc.bpel.ProcessNode, {24 constructor: function(tempParent, tempName, tempValue){25 this.collapseTrigger = null;26 this.collapsed = false;27 this.resizeTrigger = null;28 29 this.links = new Array();30 31 this.linkInformation = new Array();32 33 this.calculated = false;34 35 this.visibleNodes = new Array();36 },37 // do some settings to trigger correct rerender if child is added 38 addChild: function(child) {39 this.inherited(arguments);40 if (child instanceof bpc.bpel.ProcessNode) {41 this.changed = true;42 this.calculated = false;43 child.isVisible = true;44 child.setLayout(this.layout);45 }46 },47 48 checkIfVisible: function() {49 this.isVisible = this.layout.checkIfVisible(this);50 var hasVisibleChildren = false;51 for (var i = 0;i < this.children.length; i++) {52 if (this.children[i] instanceof bpc.bpel.ProcessNode) {53 if (this.children[i].checkIfVisible() && !hasVisibleChildren) {54 hasVisibleChildren = true;55 } 56 }57 }58 this.calculated = false;59 if (hasVisibleChildren) this.isVisible = true;60 return this.isVisible;61 },62 calculate: function() {63 // implement in subclass64 },65 getLinkInfo: function(source, target, parent) {66 if (!parent) return null;67 if (!(parent instanceof bpc.bpel.Flow)) {68 return this.getLinkInfo(source,target, parent.parent);69 }70 for (var i in this.linkInformation) {71 var mapping = this.linkInformation[i];72 if (mapping.source == source && mapping.target == target) {73 return mapping;74 }75 }76 return this.getLinkInfo(source,target, parent.parent);77 }78 ...
hasVisibleChildren.spec.js
Source:hasVisibleChildren.spec.js
...21 it('exists', function() {22 expect(tree.node(1).hasVisibleChildren).to.be.a('function');23 });24 it('returns true for parent with visible children', function() {25 expect(tree.node(1).hasVisibleChildren()).to.be.true;26 });27 it('returns false for parent without children', function() {28 expect(tree.node(2).hasVisibleChildren()).to.be.false;29 });30 it('returns false for parent with one hidden child', function() {31 tree.node(11).hide();32 expect(tree.node(1).hasVisibleChildren()).to.be.false;33 });34 it('returns true for parent with one visible, one hidden child', function() {35 tree.node(1).addChild({36 text: 'New'37 });38 expect(tree.node(1).hasVisibleChildren()).to.be.true;39 });...
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button');5 const articleHeader = await Selector('.result-content').find('h1');6 let headerText = await articleHeader.innerText;7 let headerHtml = await articleHeader.innerHTML;8 let visibleText = await articleHeader.visibleText;9 console.log(headerText);10 console.log(headerHtml);11 console.log(visibleText);12});13TypeError: Selector(...).visibleText is not a function14import { Selector } from 'testcafe';15test('My first test', async t => {16 .typeText('#developer-name', 'John Smith')17 .click('#submit-button');18 const articleHeader = await Selector('.result-content').find('h1');19 let headerText = await articleHeader.innerText;20 let headerHtml = await articleHeader.innerHTML;21 let visibleText = await articleHeader.visibleText;22 console.log(headerText);23 console.log(headerHtml);24 console.log(visibleText);25});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My test', async t => {3 .click('#populate')4 .click('#submit-button');5 const articleHeader = Selector('.result-content').find('h1');6 const hasArticleHeader = await articleHeader.hasVisibleChildren;7 await t.expect(hasArticleHeader).ok();8});9> 20 | test('My test', async t => {
Using AI Code Generation
1import { t } from 'testcafe';2import { Selector } from 'testcafe';3test('My first test', async t => {4 .typeText('#developer-name', 'John Smith')5 .click('#submit-button');6});7test('Check for visible children', async t => {8 const parent = Selector('#parent');9 const child = parent.find('div');10 const hasChildren = await child.hasVisibleChildren;11 console.log(hasChildren);12});13import { t } from 'testcafe';14import { Selector } from 'testcafe';15test('My first test', async t => {16 .typeText('#developer-name', 'John Smith')17 .click('#submit-button');18});19test('Check for visible children', async t => {20 const parent = Selector('#parent');21 const child = parent.find('div');22 const hasChildren = await child.hasVisibleChildren;23 console.log(hasChildren);24});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My Test', async t => {3 const hasChildren = await Selector('#populate').hasVisibleChildren;4 console.log(hasChildren);5});6import { Selector } from 'testcafe';7test('My Test', async t => {8 const hasChildren = await Selector('#populate').hasVisibleChildren;9 console.log(hasChildren);10});11import { Selector } from 'testcafe';12test('My Test', async t => {13 const hasChildren = await Selector('#populate').hasVisibleChildren;14 console.log(hasChildren);15});16import { Selector } from 'testcafe';17test('My Test', async t => {18 const hasChildren = await Selector('#populate').hasVisibleChildren;19 console.log(hasChildren);20});21import { Selector } from 'testcafe';22test('My Test', async t => {23 const hasChildren = await Selector('#populate').hasVisibleChildren;24 console.log(hasChildren);25});26import { Selector } from 'testcafe';27test('My Test', async t => {28 const hasChildren = await Selector('#populate').hasVisibleChildren;29 console.log(hasChildren);30});31import { Selector } from 'testcafe';
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My test', async t => {3 const select = Selector('select');4 .expect(select.hasVisibleChildren).ok()5 .expect(select.child().hasVisibleChildren).notOk();6});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3 const checkBox1 = Selector('#remote-testing');4 const checkBox2 = Selector('#reusing-js-code');5 const checkBox3 = Selector('#continuous-integration-embedding');6 const checkBox4 = Selector('#background-parallel-testing');7 const checkBox5 = Selector('#traffic-markup-analysis');8 .click(checkBox1)9 .click(checkBox2)10 .click(checkBox3)11 .click(checkBox4)12 .click(checkBox5);13 if (await checkBox1.hasVisibleChildren) {14 console.log('The checkbox1 has visible children.');15 }16 if (await checkBox2.hasVisibleChildren) {17 console.log('The checkbox2 has visible children.');18 }19 if (await checkBox3.hasVisibleChildren) {20 console.log('The checkbox3 has visible children.');21 }22 if (await checkBox4.hasVisibleChildren) {23 console.log('The checkbox4 has visible children.');24 }25 if (await checkBox5.hasVisibleChildren) {26 console.log('The checkbox5 has visible children.');27 }28});29import { Selector } from 'testcafe';30test('My first test', async t => {31 const checkBox1 = Selector('#remote-testing');32 const checkBox2 = Selector('#reusing-js-code');33 const checkBox3 = Selector('#continuous-integration-embedding');34 const checkBox4 = Selector('#background-parallel-testing');35 const checkBox5 = Selector('#traffic-markup-analysis');36 .click(checkBox1)37 .click(checkBox2)38 .click(checkBox3)
Using AI Code Generation
1import { Selector } from 'testcafe';2fixture('Testcafe Selector API')3test('Testcafe Selector API', async t => {4 const triedTestCafeCheckbox = Selector('#tried-test-cafe');5 await t.expect(triedTestCafeCheckbox.exists).ok();6 await t.expect(triedTestCafeCheckbox.hasVisibleChildren).notOk();7});8import { Selector } from 'testcafe';9fixture('Testcafe Selector API')10test('Testcafe Selector API', async t => {11 const macOSRow = Selector('label').withText('MacOS');12 await t.expect(macOSRow.exists).ok();13 await t.expect(macOSRow.visible).ok();14});15import { Selector } from 'testcafe';16fixture('Testcafe Selector API')17test('Testcafe Selector API', async t => {18 const macOSRow = Selector('label').withText('MacOS');
Using AI Code Generation
1import { Selector } from 'testcafe';2import { ClientFunction } from 'testcafe';3test('Selector API', async t => {4 .typeText('#lst-ib', 'Testcafe')5 .click('#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input[type="submit"]:nth-child(1)')6 .wait(5000)7 .expect(Selector('#rso > div:nth-child(1) > div > div > div > div > div > h3 > a').hasVisibleChildren).ok();8});9 Selector: #rso > div:nth-child(1) > div > div > div > div > div > h3 > a10 at Selector._getCallsiteName (node_modules/testcafe/lib/client-functions/selector-builder/callsite.js:15:15)11 at Selector._getCallsite (node_modules/testcafe/lib/client-functions/selector-builder/callsite.js:20:34)12 at Selector._init (node_modules/testcafe/lib/client-functions/selector-builder/index.js:65:34)13 at new Selector (node_modules/testcafe/lib/client-functions/selector-builder/index.js:52:10)14 at Object.exports.Selector (node_modules/testcafe/lib/client-functions/selectors/index.js:11:12)15 at Object.exports.ok (node_modules/testcafe/lib/api/assertions/index.js:26:23)16 at Context.<anonymous> (test.js:13:14)17 at process._tickCallback (internal
Using AI Code Generation
1import { Selector } from 'testcafe';2test('test', async t => {3 .click('#populate')4 .click('#submit-button')5 .expect(Selector('legend').hasVisibleChildren).ok();6});7 1 |import { Selector } from 'testcafe';8 6 |test('test', async t => {9 8 | .click('#populate')10 9 | .click('#submit-button')11 10 | .expect(Selector('legend').hasVisibleChildren).ok();12 11 |});13 at Object.<anonymous> (test.js:6:1)14 at Module._compile (module.js:624:30)15 at Object.Module._extensions..js (module.js:635:10)16 at Module.load (module.js:545:32)17 at tryModuleLoad (module.js:508:12)18 at Function.Module._load (module.js:500:3)19 at Module.runMain (module.js:665:10)20 at run (bootstrap_node.js:394:7)21 at startup (bootstrap_node.js:149:9)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!