demo20230512/Browser_Local/js/Directive/TabListTable.js
2023-05-12 10:20:28 +08:00

109 lines
4.8 KiB
JavaScript

/*
Logic Solution
WeeeCarbonFootprint
Template Directive
*/
angular.module('View.Directive')
.directive('tabListTable', function (CONSTANTS) {
return {
restrict: 'E',
controller: function ($scope, $filter, $cookieStore, Redirect) {
if (typeof $scope != 'undefined') $scope.SurveyOrder_Table = [{}];
$scope.tabManager = {};
var redirect = new Redirect();
var OTM = $scope.tabModel;
if (OTM == null || typeof OTM == 'undefined') return false;
//var _st = $scope.SurveyOrder_Table[0];
$scope.tabManager.tabItems = OTM.tabs;
$scope.tabManager.select = function (i) {
for (var t = 0; t < $scope.tabManager.tabItems.length; t++) {
$scope.tabManager.tabItems[t].selected = false;
}
OTM.tabs[i].selected = true;
//var name = $scope.tabManager.tabItems[i].name;
//if (typeof OTM.SURVEY_ORDER_CONFIG[name].Radio != 'undefined') {
// _st.item_radio_content = OTM.SURVEY_ORDER_CONFIG[name].Radio;
// _st.radio = OTM.SURVEY_ORDER_CONFIG[name].Radio[0];
//}
//$scope.tabManager.tabItems[i].selected = true;
//$scope.tabManager.OrderUrl = $scope.tabManager.tabItems[i].url;
//_st.Table_Header = SetCellWidth(OTM.SURVEY_ORDER_CONFIG[name].Table_Header)[0];
//_st.Table_Width = SetTableTotalWidth(_st.Table_Header, null, null);
//_st.Data_Row = $scope.tabManager.tabItems[i].datas;
////this is fake page
//$scope.page = { total_page: 10, page_lists: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] };
//$scope.tabManager.lasttab = i;
}
$scope.order = function (predicate, reverse) {
// _st.Data_Row = $filter('orderBy')(_st.Data_Row, predicate, reverse);
}
$scope.order('-ID', false);
$scope.setRadioTableHeight = function () {
//var row_count = 0;
//for (var i = 0; i < _st.Data_Row; i++) {
// if (_st.Data_Row[i].Show) row_count++;
//}
//return 29 + row_count * 31 + $scope.expand_height + 'px';
}
$scope.lastShow = function () {
//for (var i = _st.Data_Row.length - 1; i >= 0; i--) {
// if (_st.Data_Row[i].Show) {
// return _st.Data_Row[i].ID;
// }
//}
//return -1;
}
$scope.receiveRadioChange = function () {
//var radio = _st.radio;
//var radio_items = _st.item_radio_content;
//for (var i = 0; i < _st.Data_Row.length; i++) {
// _st.Data_Row[i].Show = false;
// if (radio == radio_items[0]) {
// _st.Data_Row[i].Show = true;
// } else if (radio == radio_items[1]) {
// if (_st.Data_Row[i].RepliedValue != null) _st.Data_Row[i].Show = true;
// } else if (radio == radio_items[2]) {
// if (_st.Data_Row[i].RepliedValue == null) _st.Data_Row[i].Show = true;
// }
//}
}
$scope.outerWrap = function (table) {
//var b = document.getElementsByClassName('body_content');
//if (b && (b[b.length - 1])) {//this is ulgly should be verified later
// var bw = b[b.length - 1].clientWidth;
// var tw = typeof table.Table_Width != 'undefined' ? table.Table_Width : add(table.Table_Header);
// if (bw <= tw) return '100%';
// else return tw + 'px';
//}
}
//$scope.Table_Edit = function (dr) {
// for (var t = 0, _t = $scope.tabManager.tabItems; t < $scope.tabManager.tabItems.length; t++) {
// if (_t[t].selected) {
// if (typeof dr.Id != 'undefined') $cookieStore.put(_t[t].name + '_ID', dr.Id);
// else if (typeof dr.ID != 'undefined') $cookieStore.put(_t[t].name + '_ID', dr.ID);
// window[redirect['goToCreate' + _t[t].name].call()];
// }
// }
//}
},
templateUrl: CONSTANTS.TB + 'tab_list_table'
}
})