EduSeeker

CustomP13nFilterPanel

Aug 28th, 2019
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sap.ui.define(['sap/m/P13nFilterPanel', 'br/com/sigga/components/CustomP13nConditionPanel'], function (P13nFilterPanel, CustomP13nConditionPanel) {
  2.     "use strict";
  3.     const CustomP13nFilterPanel = P13nFilterPanel.extend("br.com.sigga.components.CustomP13nFilterPanel", {
  4.         metadata: {
  5.             library: "br.com.sigga.components"
  6.         },
  7.         renderer(oRm, oControl) {
  8.             // start ConditionPanel
  9.             oRm.write("<section");
  10.             oRm.writeControlData(oControl);
  11.             oRm.addClass("sapMFilterPanel");
  12.             // oRm.addStyle("width", oControl.getWidth());
  13.             // oRm.addStyle("height", oControl.getHeight());
  14.             oRm.writeClasses();
  15.             oRm.writeStyles();
  16.             oRm.write(">");
  17.  
  18.             // render content
  19.             oRm.write("<div");
  20.             oRm.addClass("sapMFilterPanelContent");
  21.             oRm.addClass("sapMFilterPanelBG");
  22.  
  23.             oRm.writeClasses();
  24.             oRm.write(">");
  25.             const aChildren = oControl.getAggregation("content");
  26.             const iLength = aChildren.length;
  27.             for (let i = 0; i < iLength; i++) {
  28.                 oRm.renderControl(aChildren[i]);
  29.             }
  30.             oRm.write("</div>");
  31.  
  32.             oRm.write("</section>");
  33.         }
  34.     });
  35.  
  36.     CustomP13nFilterPanel.prototype.init = function () {
  37.         this.setType(sap.m.P13nPanelType.filter);
  38.         this.setTitle(sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("FILTERPANEL_TITLE"));
  39.  
  40.         sap.ui.getCore().loadLibrary("sap.ui.layout");
  41.         jQuery.sap.require("sap.ui.layout.Grid");
  42.  
  43.         sap.ui.layout.Grid.prototype.init.apply(this);
  44.  
  45.         this._aKeyFields = [];
  46.         this.addStyleClass("sapMFilterPanel");
  47.  
  48.         // init some resources
  49.         this._oRb = sap.ui.getCore().getLibraryResourceBundle("sap.m");
  50.  
  51.         this._aIncludeOperations = {};
  52.  
  53.         if (!this._aIncludeOperations.default) {
  54.             this.setIncludeOperations([
  55.                 sap.m.P13nConditionOperation.EQ, sap.m.P13nConditionOperation.BT, sap.m.P13nConditionOperation.LT, sap.m.P13nConditionOperation.LE, sap.m.P13nConditionOperation.GT, sap.m.P13nConditionOperation.GE
  56.             ]);
  57.         }
  58.  
  59.         if (!this._aIncludeOperations.string) {
  60.             this.setIncludeOperations([
  61.                 sap.m.P13nConditionOperation.Contains, sap.m.P13nConditionOperation.EQ, sap.m.P13nConditionOperation.BT, sap.m.P13nConditionOperation.StartsWith, sap.m.P13nConditionOperation.EndsWith, sap.m.P13nConditionOperation.LT, sap.m.P13nConditionOperation.LE, sap.m.P13nConditionOperation.GT, sap.m.P13nConditionOperation.GE
  62.             ], "string");
  63.         }
  64.         if (!this._aIncludeOperations.date) {
  65.             this.setIncludeOperations([
  66.                 sap.m.P13nConditionOperation.EQ, sap.m.P13nConditionOperation.BT, sap.m.P13nConditionOperation.LT, sap.m.P13nConditionOperation.LE, sap.m.P13nConditionOperation.GT, sap.m.P13nConditionOperation.GE
  67.             ], "date");
  68.         }
  69.         if (!this._aIncludeOperations.time) {
  70.             this.setIncludeOperations([
  71.                 sap.m.P13nConditionOperation.EQ, sap.m.P13nConditionOperation.BT, sap.m.P13nConditionOperation.LT, sap.m.P13nConditionOperation.LE, sap.m.P13nConditionOperation.GT, sap.m.P13nConditionOperation.GE
  72.             ], "time");
  73.         }
  74.         if (!this._aIncludeOperations.numeric) {
  75.             this.setIncludeOperations([
  76.                 sap.m.P13nConditionOperation.EQ, sap.m.P13nConditionOperation.BT, sap.m.P13nConditionOperation.LT, sap.m.P13nConditionOperation.LE, sap.m.P13nConditionOperation.GT, sap.m.P13nConditionOperation.GE
  77.             ], "numeric");
  78.         }
  79.         if (!this._aIncludeOperations.boolean) {
  80.             this.setIncludeOperations([
  81.                 sap.m.P13nConditionOperation.EQ
  82.             ], "boolean");
  83.         }
  84.  
  85.         this._aExcludeOperations = {};
  86.  
  87.         if (!this._aExcludeOperations.default) {
  88.             this.setExcludeOperations([
  89.                 sap.m.P13nConditionOperation.EQ
  90.             ]);
  91.         }
  92.  
  93.         this._oIncludePanel = new sap.m.Panel({
  94.             expanded: true,
  95.             expandable: true,
  96.             headerText: this._oRb.getText("FILTERPANEL_INCLUDES"),
  97.             width: "auto"
  98.         }).addStyleClass("sapMFilterPadding");
  99.  
  100.         this._oIncludeFilterPanel = new CustomP13nConditionPanel({
  101.             maxConditions: this.getMaxIncludes(),
  102.             alwaysShowAddIcon: false,
  103.             layoutMode: this.getLayoutMode(),
  104.             dataChange: this._handleDataChange()
  105.         });
  106.         this._oIncludeFilterPanel._sAddRemoveIconTooltipKey = "FILTER";
  107.  
  108.         for (const sType in this._aIncludeOperations) {
  109.             this._oIncludeFilterPanel.setOperations(this._aIncludeOperations[sType], sType);
  110.         }
  111.  
  112.         this._oIncludePanel.addContent(this._oIncludeFilterPanel);
  113.  
  114.         this.addAggregation("content", this._oIncludePanel);
  115.  
  116.         this._oExcludePanel = new sap.m.Panel({
  117.             expanded: false,
  118.             expandable: true,
  119.             headerText: this._oRb.getText("FILTERPANEL_EXCLUDES"),
  120.             width: "auto"
  121.         }).addStyleClass("sapMFilterPadding");
  122.  
  123.         this._oExcludeFilterPanel = new CustomP13nConditionPanel({
  124.             exclude: true,
  125.             maxConditions: this.getMaxExcludes(),
  126.             alwaysShowAddIcon: false,
  127.             layoutMode: this.getLayoutMode(),
  128.             dataChange: this._handleDataChange()
  129.         });
  130.         this._oExcludeFilterPanel._sAddRemoveIconTooltipKey = "FILTER";
  131.  
  132.         for (const sType in this._aExcludeOperations) {
  133.             this._oExcludeFilterPanel.setOperations(this._aExcludeOperations[sType], sType);
  134.         }
  135.  
  136.         this._oExcludePanel.addContent(this._oExcludeFilterPanel);
  137.  
  138.         this.addAggregation("content", this._oExcludePanel);
  139.  
  140.         this._updatePanel();
  141.     };
  142.  
  143.     return CustomP13nFilterPanel;
  144. });
Add Comment
Please, Sign In to add comment