Advertisement
Guest User

Untitled

a guest
May 24th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.82 KB | None | 0 0
  1. //@PRESS DEL TagsCustomListItem
  2. var list = [];
  3.  
  4. var item = {};
  5. item.ID_CHAR = 'COLLECTION_FLAG';
  6. item.ID_CHAR_VALUE_DESCR = 'In Collection';
  7. list.push(item);
  8.  
  9.  
  10. if (typeof(modelOrdAuthPage.getData().O_BEST_SELLER) !== "undefined" && modelOrdAuthPage.getData().O_BEST_SELLER) {
  11. var item = {};
  12. item.ID_CHAR = 'BEST_SELLER';
  13. item.ID_CHAR_VALUE_DESCR = 'Best Seller';
  14. list.push(item);
  15. }
  16.  
  17. var item = {};
  18. item.ID_CHAR = '3';
  19. item.ID_CHAR_VALUE_DESCR = 'PROPOSAL';
  20. list.push(item);
  21.  
  22. var item = {};
  23. item.ID_CHAR = 'POLARIZED_NEPT';
  24. item.ID_CHAR_VALUE_DESCR = 'Polarized';
  25. list.push(item);
  26.  
  27. var item = {};
  28. item.ID_CHAR = 'NEW_MATERIAL_NEPT';
  29. item.ID_CHAR_VALUE_DESCR = 'New Material';
  30. list.push(item);
  31.  
  32. //IF IS UNDER POLICY CHECK THAT USER HAS IT
  33. var item = {};
  34. item.ID_CHAR = 'IDEAL_ASSORTMENT';
  35. item.ID_CHAR_VALUE_DESCR = 'Ideal Assortment';
  36. list.push(item);
  37.  
  38.  
  39. modelTagsDetailFilterList.setData(list);
  40.  
  41. DetailFilterProductListText.setText(TagsObjectHeader.getTitle());
  42. _filterProductsRule = TagsCodeObjectAttribute.getTitle();
  43.  
  44.  
  45. TagsDetailFilterList.setVisible(true);
  46. DetailFilterBrandList.setVisible(false);
  47. App.to(DetailFilterPage);
  48.  
  49.  
  50.  
  51. //--------------------------------------
  52. //@SELECTION CHANGE TagsDetailFilterList
  53. //--------------------------------------
  54.  
  55. var selChangeItems = oEvent.getParameters().listItems;
  56.  
  57.  
  58. if (selChangeItems.length === 1) {
  59. var model2Update = _filterProductsRule + 'FilterActiveList';
  60. // var data2Update = window[model2Update].getData();
  61.  
  62. var data2Update = sap.ui.getCore().byId(sap.n.currentView.createId(model2Update)).getModel().getData();
  63. var object = JSON.parse(JSON.stringify(selChangeItems[0].getBindingContext().getObject()));
  64. // Add selected item
  65. if (oEvent.getParameters().selected === true) {
  66. if (typeof(data2Update.length) === "undefined")
  67. data2Update = [];
  68.  
  69. data2Update.push(object);
  70. // window[model2Update].setData(data2Update);
  71. sap.ui.getCore().byId(sap.n.currentView.createId(model2Update)).getModel().setData(data2Update);
  72. } else {
  73.  
  74. // Remove item deselected
  75. for (i = 0; i < data2Update.length; i++) {
  76. if (data2Update[i].ID_CHAR === object.ID_CHAR) {
  77. data2Update.splice(i, 1);
  78. // window[model2Update].setData(data2Update);
  79. sap.ui.getCore().byId(sap.n.currentView.createId(model2Update)).getModel().setData(data2Update);
  80. return;
  81. }
  82.  
  83. }
  84. }
  85.  
  86.  
  87. }
  88.  
  89.  
  90.  
  91. //--------------------------------------
  92. //@ PRESS DetailFilterProductListBackBut
  93. //--------------------------------------
  94.  
  95. var modelFilterApply = _filterProductsRule + 'FilterActiveList';
  96. var objAttributeApply = _filterProductsRule + 'ObjectAttribute';
  97. var cancelButApply = _filterProductsRule + 'CancelButton';
  98.  
  99. var modelData = sap.ui.getCore().byId(sap.n.currentView.createId(modelFilterApply)).getModel().getData();
  100.  
  101. if (modelData.length > 0) {
  102.  
  103. sap.ui.getCore().byId(sap.n.currentView.createId(objAttributeApply)).setVisible(true);
  104. sap.ui.getCore().byId(sap.n.currentView.createId(cancelButApply)).setVisible(true);
  105.  
  106. if (modelData.length > 3) {
  107. sap.ui.getCore().byId(sap.n.currentView.createId(objAttributeApply)).setText(modelData.length + " " + NoItemsSelectedText.getText());
  108. } else {
  109. var textToApply = "";
  110. for (i = 0; i < modelData.length; i++) {
  111. if (i !== modelData.length - 1)
  112. textToApply = textToApply + modelData[i].ID_CHAR_VALUE_DESCR + ", ";
  113. else
  114. textToApply = textToApply + modelData[i].ID_CHAR_VALUE_DESCR
  115. }
  116.  
  117. sap.ui.getCore().byId(sap.n.currentView.createId(objAttributeApply)).setText(textToApply);
  118. }
  119. } else {
  120. sap.ui.getCore().byId(sap.n.currentView.createId(objAttributeApply)).setVisible(false);
  121. sap.ui.getCore().byId(sap.n.currentView.createId(objAttributeApply)).setText("");
  122. sap.ui.getCore().byId(sap.n.currentView.createId(cancelButApply)).setVisible(false);
  123. }
  124.  
  125. switch (_filterProductsRule) {
  126.  
  127. case FrontColourCodeObjectAttribute.getTitle():
  128. _frontColourFilter = [];
  129. if (modelData.length > 0) {
  130. var selectConditionConc = "";
  131. for (i = 0; i < modelData.length; i++) {
  132. if (i !== modelData.length - 1)
  133. selectConditionConc = selectConditionConc + ' FRONT_COLOUR = "' + modelData[i].ID_CHAR_VALUE + '" OR ';
  134. else
  135. selectConditionConc = selectConditionConc + ' FRONT_COLOUR = "' + modelData[i].ID_CHAR_VALUE + '")';
  136. }
  137.  
  138. var selectStatement = 'SELECT * FROM GT_PRD_GRD_LIST_DATA WHERE (' + selectConditionConc +
  139. //AT Grids
  140. ' AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER <> "' +
  141. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG +
  142. '" AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER = "' +
  143. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG + '"))';
  144.  
  145.  
  146. AppDB.transaction(function(tx) {
  147. tx.executeSql(selectStatement, [], function(tx, res) {
  148.  
  149. var filter;
  150. var filterSet = [];
  151. for (var j = 0; j < res.rows.length; j++) {
  152. filter = new sap.ui.model.Filter("PRODUCT", "EQ", res.rows.item(j).PRODUCT);
  153. filterSet.push(filter);
  154. }
  155.  
  156. _frontColourFilter = new sap.ui.model.Filter(filterSet, false);
  157. });
  158. });
  159. }
  160. break;
  161.  
  162. case LensMatCodeObjectAttribute.getTitle():
  163. _lensMatFilter = [];
  164. if (modelData.length > 0) {
  165. var selectConditionConc = "";
  166. for (i = 0; i < modelData.length; i++) {
  167. if (i !== modelData.length - 1)
  168. selectConditionConc = selectConditionConc + ' LENS_MATERIAL = "' + modelData[i].ID_CHAR_VALUE + '" OR ';
  169. else
  170. selectConditionConc = selectConditionConc + ' LENS_MATERIAL = "' + modelData[i].ID_CHAR_VALUE + '")';
  171.  
  172. }
  173.  
  174. var selectStatement = 'SELECT * FROM GT_PRD_GRD_LIST_DATA WHERE (' + selectConditionConc +
  175. //AT Grids
  176. ' AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER <> "' +
  177. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG +
  178. '" AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER = "' +
  179. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG + '"))';
  180.  
  181.  
  182. AppDB.transaction(function(tx) {
  183. tx.executeSql(selectStatement, [], function(tx, res) {
  184.  
  185. var filter;
  186. var filterSet = [];
  187. for (var j = 0; j < res.rows.length; j++) {
  188. filter = new sap.ui.model.Filter("PRODUCT", "EQ", res.rows.item(j).PRODUCT);
  189. filterSet.push(filter);
  190. }
  191. _lensMatFilter = new sap.ui.model.Filter(filterSet, false);
  192.  
  193. });
  194. });
  195. }
  196. break;
  197.  
  198. case LensPropCodeObjectAttribute.getTitle():
  199. _lensPropFilter = [];
  200. if (modelData.length > 0) {
  201. var selectConditionConc = "";
  202. for (i = 0; i < modelData.length; i++) {
  203. if (i !== modelData.length - 1)
  204. selectConditionConc = selectConditionConc + ' LENS_PROPERTIES = "' + modelData[i].ID_CHAR_VALUE + '" OR ';
  205. else
  206. selectConditionConc = selectConditionConc + ' LENS_PROPERTIES = "' + modelData[i].ID_CHAR_VALUE + '")';
  207. }
  208.  
  209. var selectStatement = 'SELECT * FROM GT_PRD_GRD_LIST_DATA WHERE (' + selectConditionConc +
  210. //AT Grids
  211. ' AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER <> "' +
  212. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG +
  213. '" AND GT_PRD_GRD_LIST_DATA.GRID_VALUE NOT IN (SELECT GRID_VALUE FROM GT_PRD_GRD_CAT_EXCL WHERE PARTNER = "' +
  214. modelOrderDetailPage.getData().CUSTOMER + '" AND SALES_ORG = "' + modelUserProfilePage.getData().ZVKORG + '"))';
  215.  
  216.  
  217. AppDB.transaction(function(tx) {
  218. tx.executeSql(selectStatement, [], function(tx, res) {
  219.  
  220. var filter;
  221. var filterSet = [];
  222. for (var j = 0; j < res.rows.length; j++) {
  223. filter = new sap.ui.model.Filter("PRODUCT", "EQ", res.rows.item(j).PRODUCT);
  224. filterSet.push(filter);
  225. }
  226.  
  227. _lensPropFilter = new sap.ui.model.Filter(filterSet, false);
  228.  
  229. });
  230. });
  231. }
  232. break;
  233.  
  234.  
  235. //MT:ACX fix compatibility filter
  236. case CompAcxCodeObjectAttribute.getTitle():
  237. //Hiding Compatibility List
  238. DetailFilterList.setVisible(true);
  239. BrandProductListFiltAcxSubBar.setVisible(false);
  240. BrandPrdFiltAcxScrollContainer.setVisible(false);
  241. _compAcxFilter = [];
  242. if (modelData.length > 0) {
  243. var selectConditionConc = "";
  244. for (i = 0; i < modelData.length; i++) {
  245. if (i !== modelData.length - 1)
  246. selectConditionConc = selectConditionConc + ' PRODUCT = "' + modelData[i].ID_CHAR_VALUE + '" OR ';
  247. else
  248. selectConditionConc = selectConditionConc + ' PRODUCT = "' + modelData[i].ID_CHAR_VALUE + '")';
  249.  
  250. }
  251.  
  252. AppDB.transaction(function(tx) {
  253. tx.executeSql('SELECT PRODUCT_ACX FROM GT_ACX_RELATIONSHIP WHERE (' + selectConditionConc, [], function(tx, res) {
  254.  
  255. var filter;
  256. var filterSet = [];
  257. for (var j = 0; j < res.rows.length; j++) {
  258. filter = new sap.ui.model.Filter("PRODUCT", "EQ", res.rows.item(j).PRODUCT_ACX);
  259. filterSet.push(filter);
  260. }
  261.  
  262. _compAcxFilter = new sap.ui.model.Filter(filterSet, false);
  263.  
  264. });
  265. });
  266. }
  267. break;
  268. }
  269. App.back();
  270.  
  271.  
  272.  
  273. //-------------------------------------------------
  274. //@ FilterProductListApplyButton PRESS EVENT
  275. //-------------------------------------------------
  276.  
  277.  
  278. var filterSet = [];
  279. var globalFilter = [];
  280. var filter;
  281. var filterValue;
  282. var countFilterActive = 0;
  283. _counterFilterAcx = 0;
  284. // Remove all filters as first step
  285. var binding = BrandProductFiltGrid.getBinding("items");
  286. binding.filter([]);
  287.  
  288. var bindingList = BrandProductFiltList.getBinding("items");
  289. bindingList.filter([]);
  290.  
  291.  
  292. if (modelGenderFilterActiveList.getData().length > 0) {
  293.  
  294. filterSet = [];
  295. for (i = 0; i < modelGenderFilterActiveList.getData().length; i++) {
  296. filterValue = modelGenderFilterActiveList.getData()[i].ID_CHAR_VALUE;
  297. filter = new sap.ui.model.Filter("GENDER", "EQ", filterValue);
  298. filterSet.push(filter);
  299. }
  300.  
  301. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  302. countFilterActive += 1;
  303.  
  304. }
  305.  
  306. if (modelCollectionFilterActiveList.getData().length > 0) {
  307.  
  308. filterSet = [];
  309. for (i = 0; i < modelCollectionFilterActiveList.getData().length; i++) {
  310. filterValue = modelCollectionFilterActiveList.getData()[i].ID_CHAR_VALUE;
  311. filter = new sap.ui.model.Filter("CATEGORY", "EQ", filterValue);
  312. filterSet.push(filter);
  313. }
  314.  
  315. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  316. countFilterActive += 1;
  317. }
  318.  
  319. if (modelAgeFilterActiveList.getData().length > 0) {
  320.  
  321. filterSet = [];
  322. for (i = 0; i < modelAgeFilterActiveList.getData().length; i++) {
  323. filterValue = modelAgeFilterActiveList.getData()[i].ID_CHAR_VALUE;
  324. filter = new sap.ui.model.Filter("AGE_RANGE", "EQ", filterValue);
  325. filterSet.push(filter);
  326. }
  327.  
  328. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  329. countFilterActive += 1;
  330. }
  331.  
  332. if (modelTagsFilterActiveList.getData().length > 0) {
  333.  
  334. filterSet = [];
  335. for (i = 0; i < modelTagsFilterActiveList.getData().length; i++) {
  336. var fieldName = modelTagsFilterActiveList.getData()[i].ID_CHAR;
  337. filter = new sap.ui.model.Filter(fieldName, "EQ", true);
  338. filterSet.push(filter);
  339. }
  340.  
  341. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  342. countFilterActive += 1;
  343. }
  344.  
  345.  
  346. if (modelShapeFilterActiveList.getData().length > 0) {
  347.  
  348. filterSet = [];
  349. for (i = 0; i < modelShapeFilterActiveList.getData().length; i++) {
  350. filterValue = modelShapeFilterActiveList.getData()[i].ID_CHAR_VALUE;
  351. filter = new sap.ui.model.Filter("SHAPE", "EQ", filterValue);
  352. filterSet.push(filter);
  353. }
  354.  
  355. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  356. countFilterActive += 1;
  357. }
  358.  
  359. if (modelMaterialFilterActiveList.getData().length > 0) {
  360.  
  361. filterSet = [];
  362. for (i = 0; i < modelMaterialFilterActiveList.getData().length; i++) {
  363. filterValue = modelMaterialFilterActiveList.getData()[i].ID_CHAR_VALUE;
  364. filter = new sap.ui.model.Filter("FRONT_MATERIAL", "EQ", filterValue);
  365. filterSet.push(filter);
  366. }
  367.  
  368. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  369. countFilterActive += 1;
  370. }
  371.  
  372. if (modelGeoFitFilterActiveList.getData().length > 0) {
  373.  
  374. filterSet = [];
  375. for (i = 0; i < modelGeoFitFilterActiveList.getData().length; i++) {
  376. filterValue = modelGeoFitFilterActiveList.getData()[i].ID_CHAR_VALUE;
  377. filter = new sap.ui.model.Filter("GEOFIT", "EQ", filterValue);
  378. filterSet.push(filter);
  379. }
  380.  
  381. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  382. countFilterActive += 1;
  383. }
  384.  
  385. if (modelLensBaseFilterActiveList.getData().length > 0) {
  386.  
  387. filterSet = [];
  388. for (i = 0; i < modelLensBaseFilterActiveList.getData().length; i++) {
  389. filterValue = modelLensBaseFilterActiveList.getData()[i].ID_CHAR_VALUE;
  390. filter = new sap.ui.model.Filter("BASE", "EQ", filterValue);
  391. filterSet.push(filter);
  392. }
  393.  
  394. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  395. countFilterActive += 1;
  396. }
  397.  
  398. if (modelBrandFilterActiveList.getData().length > 0) {
  399.  
  400. filterSet = [];
  401. for (i = 0; i < modelBrandFilterActiveList.getData().length; i++) {
  402. filterValue = modelBrandFilterActiveList.getData()[i].BRAND_ID;
  403. filter = new sap.ui.model.Filter("BRAND_ID", "EQ", filterValue);
  404. filterSet.push(filter);
  405. }
  406.  
  407. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  408. countFilterActive += 1;
  409. }
  410.  
  411. if (modelColourAcxFilterActiveList.getData().length > 0) {
  412.  
  413. filterSet = [];
  414. for (i = 0; i < modelColourAcxFilterActiveList.getData().length; i++) {
  415. filterValue = modelColourAcxFilterActiveList.getData()[i].ID_CHAR_VALUE;
  416. filter = new sap.ui.model.Filter("NORMALIZED_COLTX", "EQ", filterValue);
  417. filterSet.push(filter);
  418. }
  419.  
  420. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  421. countFilterActive += 1;
  422. _counterFilterAcx += 1;
  423. }
  424.  
  425. if (modelLensPropAcxFilterActiveList.getData().length > 0) {
  426.  
  427. filterSet = [];
  428. for (i = 0; i < modelLensPropAcxFilterActiveList.getData().length; i++) {
  429. filterValue = modelLensPropAcxFilterActiveList.getData()[i].ID_CHAR_VALUE;
  430. filter = new sap.ui.model.Filter("LENS_PROPERTY", "EQ", filterValue);
  431. filterSet.push(filter);
  432. }
  433.  
  434. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  435. countFilterActive += 1;
  436. _counterFilterAcx += 1;
  437. }
  438.  
  439. if (modelCategoryAcxFilterActiveList.getData().length > 0) {
  440.  
  441. filterSet = [];
  442. for (i = 0; i < modelCategoryAcxFilterActiveList.getData().length; i++) {
  443. filterValue = modelCategoryAcxFilterActiveList.getData()[i].ID_CHAR_VALUE;
  444. filter = new sap.ui.model.Filter("SUBCATEGORY", "EQ", filterValue);
  445. filterSet.push(filter);
  446. }
  447.  
  448. globalFilter.push(new sap.ui.model.Filter(filterSet, false));
  449. countFilterActive += 1;
  450. _counterFilterAcx += 1;
  451. }
  452.  
  453. if (_compAcxFilter.length !== 0) {
  454. globalFilter.push(_compAcxFilter);
  455. countFilterActive += 1;
  456. _counterFilterAcx += 1;
  457. }
  458.  
  459.  
  460. if (_frontColourFilter.length !== 0) {
  461. globalFilter.push(_frontColourFilter);
  462. countFilterActive += 1;
  463. }
  464.  
  465. if (_lensMatFilter.length !== 0) {
  466. globalFilter.push(_lensMatFilter);
  467. countFilterActive += 1;
  468. }
  469.  
  470. if (_lensPropFilter.length !== 0) {
  471. globalFilter.push(_lensPropFilter);
  472. countFilterActive += 1;
  473. }
  474.  
  475. // Final filter
  476.  
  477. if (globalFilter.length > 0) {
  478. _filterByPage = _filterByPage.concat(globalFilter);
  479. var bindingList = BrandProductFiltList.getBinding("items");
  480. var binding = BrandProductFiltGrid.getBinding("items");
  481. if (_filterBySearch.length > 0) {
  482. globalFilter.push(_filterBySearch[0]);
  483. }
  484.  
  485. //change filter for acx
  486. if (_counterFilterAcx > 0) {
  487. var bindingAcx = BrandProductAcxSupportList.getBinding("items");
  488. bindingAcx.filter(new sap.ui.model.Filter(globalFilter, true));
  489.  
  490. var unique = {};
  491. var distinct = [];
  492. var array = [];
  493. var totalArray = modelBrandProductAcxSupportList.getData();
  494. if (bindingAcx.aIndices.length > 0) {
  495. for (i = 0; i < bindingAcx.aIndices.length; i++) {
  496. var indexAcx = bindingAcx.aIndices[i];
  497. array.push(JSON.parse(JSON.stringify(modelBrandProductAcxSupportList.getData()[indexAcx])));
  498. }
  499. }
  500.  
  501. var cartId = modelOrderDetailPage.getData().CART_ID;
  502. var parkedItems = modelSaParkedItemsList.getData();
  503. if (parkedItems.length > 0) {
  504. parkedItems = parkedItems.filter(function(el) {
  505. return el.CART_ID === cartId;
  506. });
  507. }
  508. if (array.length > 0) {
  509. distinct = array.filter(function(el) {
  510. if (typeof(unique[el.PRODUCT]) === "undefined") {
  511. unique[el.PRODUCT] = 0;
  512. if (parkedItems.length > 0) {
  513. el.QTY_ORDER_PROD = parkedItems.reduce(function(n, obj) {
  514. return n + (el.PRODUCT == obj.PRODUCT) * parseFloat(obj.QTY_ORDER);
  515. }, 0);
  516. }
  517.  
  518. if (el.QTY_ORDER_PROD > 0) {
  519. el.QTY_ORDER_VISIBLE = true;
  520. }
  521. var priceMin = el.O_PRICE;
  522. var newMat = false;
  523. var bestSell = false;
  524. el.COLOURS_NUM = totalArray.reduce(function(n, col) {
  525. if (el.PRODUCT === col.PRODUCT && col.O_PRICE < priceMin) {
  526. priceMin = col.O_PRICE;
  527. }
  528. if (el.PRODUCT === col.PRODUCT && col.NEW_MATERIAL_NEPT === true) {
  529. newMat = true;
  530. el.NEW_MATERIAL = "X";
  531. }
  532. if (el.PRODUCT === col.PRODUCT && col.BEST_SELLER === true) {
  533. bestSell = true;
  534. }
  535. return n + (el.PRODUCT === col.PRODUCT);
  536. }, 0);
  537. el.O_PRICE = priceMin;
  538. el.NEW_MATERIAL_NEPT = newMat;
  539. el.BEST_SELLER = bestSell;
  540. el.SIZES_NUM = 1;
  541. var coloursNum;
  542. var sizesNum;
  543.  
  544. if (typeof(el.COLOURS_NUM) === "undefined" || el.COLOURS_NUM === null || el.COLOURS_NUM === "") {
  545. coloursNum = 0;
  546. } else {
  547. coloursNum = el.COLOURS_NUM;
  548. }
  549. if (typeof(el.SIZES_NUM) === "undefined" || el.SIZES_NUM === null || el.SIZES_NUM === "") {
  550. sizesNum = 0;
  551. } else {
  552. sizesNum = el.SIZES_NUM;
  553. }
  554.  
  555. var MyColSize = ColourSizeLabel.getText();
  556. MyColSize = MyColSize.replace("&1", coloursNum);
  557. MyColSize = MyColSize.replace("&2", sizesNum);
  558. el.COLOURS_NUM = MyColSize;
  559.  
  560. return el;
  561. }
  562. })
  563. }
  564.  
  565. modelBrandProductFiltGrid.setData(JSON.parse(JSON.stringify(distinct)));
  566. modelBrandProductFiltList.setData(JSON.parse(JSON.stringify(distinct)));
  567.  
  568. BrandProductListText.setText(SelectAccessories.getText() + ' (' + distinct.length + ')');
  569.  
  570.  
  571. var indices = BrandProductFiltGrid.getBinding("items").aIndices;
  572. var productModel = modelBrandProductFiltGrid.getData();
  573. _log = [];
  574. indicesLength = indices.length;
  575.  
  576. for (i = indicesLength; i--;) {
  577. var index = indices[i];
  578. _log.push(JSON.parse(JSON.stringify(productModel[index])));
  579. }
  580. } else {
  581. bindingList.filter(new sap.ui.model.Filter(globalFilter, true));
  582. binding.filter(new sap.ui.model.Filter(globalFilter, true));
  583. }
  584. } else {
  585. if (_isAccessory) {
  586. _counterFilterAcx = 1; //dummy needed to clear the filter inside called function
  587. removeFilters();
  588. }
  589. _filterByPage = [];
  590. var bindingList = BrandProductFiltList.getBinding("items");
  591. var binding = BrandProductFiltGrid.getBinding("items");
  592. if (_filterBySearch.length > 0) {
  593. globalFilter.push(_filterBySearch[0]);
  594. bindingList.filter(_filterBySearch[0]);
  595. binding.filter(_filterBySearch[0]);
  596. }
  597. }
  598.  
  599.  
  600. var bindingList = BrandProductFiltList.getBinding("items");
  601. var binding = BrandProductFiltGrid.getBinding("items");
  602. if (globalFilter.length > 0) {
  603. // bindingList.filter(new sap.ui.model.Filter(globalFilter, true));
  604. } else {
  605. bindingList.filter([]);
  606. binding.filter([]);
  607. }
  608. App.backToPage(BrandProductListPage);
  609. ProductFilterButton.setText(FilterButtonBaseText.getText() + " (" + countFilterActive + ")");
  610. ProductFilterButton.setType("Emphasized");
  611.  
  612. //Reset the Customers List page label
  613. BrandProductListText.setText(ProductText.getText() + " (" + sap.ui.getCore().byId(sap.n.currentView.createId("BrandProductFiltGrid")).getBinding("items").aIndices.length + ")");
  614.  
  615.  
  616.  
  617. //-----------------------------------------------------------------------
  618. //@global script
  619. //-----------------------------------------------------------------------
  620.  
  621. function removeFilters() {
  622.  
  623. var bindingDet = DetailFilterList.getBinding("items");
  624. bindingDet.filter([]);
  625.  
  626. var binding = BrandProductFiltGrid.getBinding("items");
  627. binding.filter([]);
  628.  
  629. var bindingList = BrandProductFiltList.getBinding("items");
  630. bindingList.filter([]);
  631.  
  632. var bindingAcx = BrandProductAcxSupportList.getBinding("items");
  633. bindingAcx.filter([]);
  634.  
  635. _frontColourFilter = [];
  636. _lensMatFilter = [];
  637. _lensPropFilter = [];
  638.  
  639. modelBrandFilterActiveList.setData([]);
  640. BrandObjectAttribute.setVisible(false);
  641. BrandCancelButton.setVisible(false);
  642.  
  643. modelCollectionFilterActiveList.setData([]);
  644. CollectionObjectAttribute.setVisible(false);
  645. CollectionCancelButton.setVisible(false);
  646.  
  647.  
  648. modelAgeFilterActiveList.setData([]);
  649. AgeObjectAttribute.setVisible(false);
  650. AgeCancelButton.setVisible(false);
  651.  
  652. modelTagsFilterActiveList.setData([]);
  653. TagsObjectAttribute.setVisible(false);
  654. TagsCancelButton.setVisible(false);
  655.  
  656. modelGenderFilterActiveList.setData([]);
  657. GenderObjectAttribute.setVisible(false);
  658. GenderCancelButton.setVisible(false);
  659.  
  660. modelShapeFilterActiveList.setData([]);
  661. ShapeObjectAttribute.setVisible(false);
  662. ShapeCancelButton.setVisible(false);
  663.  
  664.  
  665.  
  666. modelFrontColourFilterActiveList.setData([]);
  667. FrontColourObjectAttribute.setVisible(false);
  668. FrontColourCancelButton.setVisible(false);
  669.  
  670.  
  671. modelMaterialFilterActiveList.setData([]);
  672. MaterialObjectAttribute.setVisible(false);
  673. MaterialCancelButton.setVisible(false);
  674.  
  675.  
  676. modelGeoFitFilterActiveList.setData([]);
  677. GeoFitObjectAttribute.setVisible(false);
  678. GeoFitCancelButton.setVisible(false);
  679.  
  680.  
  681.  
  682. modelLensPropFilterActiveList.setData([]);
  683. LensPropObjectAttribute.setVisible(false);
  684. LensPropCancelButton.setVisible(false);
  685.  
  686.  
  687.  
  688. modelLensMatFilterActiveList.setData([]);
  689. LensMatObjectAttribute.setVisible(false);
  690. LensMatCancelButton.setVisible(false);
  691.  
  692.  
  693. modelLensBaseFilterActiveList.setData([]);
  694. LensBaseObjectAttribute.setVisible(false);
  695. LensBaseCancelButton.setVisible(false);
  696.  
  697.  
  698. modelCategoryAcxFilterActiveList.setData([]);
  699. CategoryAcxObjectAttribute.setVisible(false);
  700. CategoryAcxCancelButton.setVisible(false);
  701.  
  702. modelLensPropAcxFilterActiveList.setData([]);
  703. LensPropAcxObjectAttribute.setVisible(false);
  704. LensPropAcxCancelButton.setVisible(false);
  705.  
  706. modelColourAcxFilterActiveList.setData([]);
  707. ColourAcxObjectAttribute.setVisible(false);
  708. ColourAcxCancelButton.setVisible(false);
  709.  
  710. modelCompAcxFilterActiveList.setData([]);
  711. CompAcxObjectAttribute.setVisible(false);
  712. CompAcxCancelButton.setVisible(false);
  713.  
  714. if (_counterFilterAcx > 0) {
  715. var unique = {};
  716. var distinct = [];
  717. var array = [];
  718. array = JSON.parse(JSON.stringify(modelBrandProductAcxSupportList.getData()));
  719. var cartId = modelOrderDetailPage.getData().CART_ID;
  720. var parkedItems = modelSaParkedItemsList.getData();
  721. if (parkedItems.length > 0) {
  722. parkedItems = parkedItems.filter(function(el) {
  723. return el.CART_ID === cartId;
  724. });
  725. }
  726. if (array.length > 0) {
  727. distinct = array.filter(function(el) {
  728. if (typeof(unique[el.PRODUCT]) === "undefined") {
  729. unique[el.PRODUCT] = 0;
  730.  
  731. if (parkedItems.length > 0) {
  732. el.QTY_ORDER_PROD = parkedItems.reduce(function(n, obj) {
  733. return n + (el.PRODUCT == obj.PRODUCT) * parseFloat(obj.QTY_ORDER);
  734. }, 0);
  735. }
  736. var priceMin = el.O_PRICE;
  737. var newMat = false;
  738. var bestSell = false;
  739. el.COLOURS_NUM = array.reduce(function(n, col) {
  740. if (el.PRODUCT === col.PRODUCT && col.O_PRICE < priceMin) {
  741. priceMin = col.O_PRICE;
  742. }
  743. if (el.PRODUCT === col.PRODUCT && col.NEW_MATERIAL_NEPT === true) {
  744. newMat = true;
  745. el.NEW_MATERIAL = "X";
  746. }
  747. if (el.PRODUCT === col.PRODUCT && col.BEST_SELLER === true) {
  748. bestSell = true;
  749. }
  750. return n + (el.PRODUCT === col.PRODUCT);
  751. }, 0);
  752. el.O_PRICE = priceMin;
  753. el.NEW_MATERIAL_NEPT = newMat;
  754. el.BEST_SELLER = bestSell;
  755. el.SIZES_NUM = 1;
  756. var coloursNum;
  757. var sizesNum;
  758.  
  759. if (typeof(el.COLOURS_NUM) === "undefined" || el.COLOURS_NUM === null || el.COLOURS_NUM === "") {
  760. coloursNum = 0;
  761. } else {
  762. coloursNum = el.COLOURS_NUM;
  763. }
  764. if (typeof(el.SIZES_NUM) === "undefined" || el.SIZES_NUM === null || el.SIZES_NUM === "") {
  765. sizesNum = 0;
  766. } else {
  767. sizesNum = el.SIZES_NUM;
  768. }
  769.  
  770. var MyColSize = ColourSizeLabel.getText();
  771. MyColSize = MyColSize.replace("&1", coloursNum);
  772. MyColSize = MyColSize.replace("&2", sizesNum);
  773. el.COLOURS_NUM = MyColSize;
  774. if (el.QTY_ORDER_PROD > 0) {
  775. el.QTY_ORDER_VISIBLE = true;
  776. }
  777.  
  778. return el;
  779. }
  780. })
  781.  
  782. }
  783.  
  784. modelBrandProductFiltGrid.setData(JSON.parse(JSON.stringify(distinct)));
  785. modelBrandProductFiltList.setData(JSON.parse(JSON.stringify(distinct)));
  786.  
  787. BrandProductListText.setText(SelectAccessories.getText() + ' (' + distinct.length + ')');
  788.  
  789.  
  790. var indices = BrandProductFiltGrid.getBinding("items").aIndices;
  791. var productModel = modelBrandProductFiltGrid.getData();
  792. _log = [];
  793. indicesLength = indices.length;
  794.  
  795. for (i = indicesLength; i--;) {
  796. // for (i = 0; i < indices.length; i++) {
  797. var index = indices[i];
  798. _log.push(JSON.parse(JSON.stringify(productModel[index])));
  799.  
  800. }
  801. }
  802.  
  803. _counterFilterAcx = 0;
  804.  
  805. DetailFilterList.removeSelections();
  806. TagsDetailFilterList.removeSelections();
  807. BrandPrdFiltCompAcx.removeSelections();
  808.  
  809. ProductFilterButton.setText(FilterButtonBaseText.getText());
  810. ProductFilterButton.setType("Default");
  811. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement