Advertisement
Wity

Untitled

Oct 23rd, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Copyright (C) 2005-2012 Alfresco Software Limited.
  3.  *
  4.  * This file is part of Alfresco
  5.  *
  6.  * Alfresco is free software: you can redistribute it and/or modify
  7.  * it under the terms of the GNU Lesser General Public License as published by
  8.  * the Free Software Foundation, either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * Alfresco is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public License
  17.  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. /**
  21.  * @module DocumentLibrary
  22.  */
  23.  
  24. /**
  25.  * Table view extension of DocumentListViewRenderer component.
  26.  *
  27.  * @namespace Alfresco
  28.  * @class Alfresco.DocumentListTableViewRenderer
  29.  * @extends Alfresco.DocumentListViewRenderer
  30.  */
  31. (function() {
  32.     /**
  33.      * YUI Library aliases
  34.      */
  35.     var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, Anim = YAHOO.util.Anim;
  36.  
  37.     /**
  38.      * Alfresco Slingshot aliases
  39.      */
  40.     var $html = Alfresco.util.encodeHTML, $isValueSet = Alfresco.util.isValueSet;
  41.  
  42.     var DND_CONTAINER_ID = 'ygddfdiv';
  43.  
  44.     /**
  45.      * TableViewRenderer constructor.
  46.      *
  47.      * @param name
  48.      *            {String} The name of the TableViewRenderer
  49.      * @return {Alfresco.DocumentListTableViewRenderer} The new
  50.      *         TableViewRenderer instance
  51.      * @constructor
  52.      */
  53.  
  54.     // -------------------------TOHLE
  55.  
  56.     Alfresco.DocumentListTableViewRenderer = function(name, parentDocumentList,
  57.             commonComponentStyle, jsonConfig) {
  58.         Alfresco.DocumentListTableViewRenderer.superclass.constructor.call(
  59.                 this, name, parentDocumentList, commonComponentStyle);
  60.         this.actionsSplitAtModifier = 0;
  61.         if (jsonConfig != null) {
  62.             this.jsonConfig = jsonConfig;
  63.             this.additionalJsonConfig = YAHOO.lang.JSON.parse(jsonConfig);
  64.         } else {
  65.             this.additionalJsonConfig = {};
  66.         }
  67.         YAHOO.Bubbling.fire("registerRenderer", {
  68.             propertyName : "fato:celkovacena",
  69.             renderer : function attachments_renderer(record, label) {
  70.  
  71.                 var jsNode = record.jsNode, properties = jsNode.properties;
  72.  
  73.                 var finalValue = properties['fato:celkovacena'];
  74.  
  75.                 if(finalValue == null || finalValue == "") {
  76.                     return;
  77.                 }   
  78.                 // Zavolání funkce na separaci mezer
  79.                 console.log(finalValue.valueOf());
  80.                 finalValue = numberWithSpaces(finalValue);
  81.  
  82.                 return '<div id="castka" style="text-align: right">'
  83.                         + finalValue + " " + "Kč" + '</div>';
  84.             }
  85.         });
  86.         YAHOO.Bubbling.fire("registerRenderer", {
  87.             propertyName : "fato:zbyvavyfakturovat",
  88.             renderer : function attachments_renderer(record, label) {
  89.  
  90.                 var jsNode = record.jsNode, properties = jsNode.properties;
  91.  
  92.                 var finalValue = properties['fato:zbyvavyfakturovat'];
  93.  
  94.                 if(finalValue == null || finalValue == "") {
  95.                     return;
  96.                 }   
  97.                 // Zavolání funkce na separaci mezer
  98.                 console.log(finalValue.valueOf());
  99.                 finalValue = numberWithSpaces(finalValue);
  100.  
  101.                 return '<div id="castka" style="text-align: right">'
  102.                         + finalValue + " " + "Kč" + '</div>';
  103.             }
  104.         });
  105.         YAHOO.Bubbling.fire("registerRenderer", {
  106.             propertyName : "fato:vysepokutyhavarijni",
  107.             renderer : function attachments_renderer(record, label) {
  108.  
  109.                 var jsNode = record.jsNode, properties = jsNode.properties;
  110.  
  111.                 var finalValue = properties['fato:vysepokutyhavarijni'];
  112.  
  113.                 if(finalValue == null || finalValue == "") {
  114.                     return;
  115.                 }   
  116.                 // Zavolání funkce na separaci mezer
  117.                 console.log(finalValue.valueOf());
  118.                 finalValue = numberWithSpaces(finalValue);
  119.  
  120.                 return '<div id="castka" style="text-align: right">'
  121.                         + finalValue + " " + "Kč" + '</div>';
  122.             }
  123.         });
  124.         YAHOO.Bubbling.fire("registerRenderer", {
  125.             propertyName : "fato:celkovacenasubdodavky",
  126.             renderer : function attachments_renderer(record, label) {
  127.  
  128.                 var jsNode = record.jsNode, properties = jsNode.properties;
  129.  
  130.                 var finalValue = properties['fato:celkovacenasubdodavky'];
  131.  
  132.                 if(finalValue == null || finalValue == "") {
  133.                     return;
  134.                 }   
  135.                 // Zavolání funkce na separaci mezer
  136.                 console.log(finalValue.valueOf());
  137.                 finalValue = numberWithSpaces(finalValue);
  138.  
  139.                 return '<div id="castka" style="text-align: right">'
  140.                         + finalValue + " " + "Kč" + '</div>';
  141.             }
  142.         });
  143.         YAHOO.Bubbling.fire("registerRenderer", {
  144.             propertyName : "fato:vyfakturovano",
  145.             renderer : function attachments_renderer(record, label) {
  146.  
  147.                 var jsNode = record.jsNode, properties = jsNode.properties;
  148.  
  149.                 var finalValue = properties['fato:vyfakturovano'];
  150.  
  151.                 if(finalValue == null || finalValue == "") {
  152.                     return;
  153.                 }   
  154.                 // Zavolání funkce na separaci mezer
  155.                 console.log(finalValue.valueOf());
  156.                 finalValue = numberWithSpaces(finalValue);
  157.  
  158.                 return '<div id="castka" style="text-align: right">'
  159.                         + finalValue + " " + "Kč" + '</div>';
  160.             }
  161.         });
  162.         YAHOO.Bubbling.fire("registerRenderer", {
  163.             propertyName : "fato:zbyvajiciprostredkysubdodavky",
  164.             renderer : function attachments_renderer(record, label) {
  165.  
  166.                 var jsNode = record.jsNode, properties = jsNode.properties;
  167.  
  168.                 var finalValue = properties['fato:zbyvajiciprostredkysubdodavky'];
  169.  
  170.                 if(finalValue == null || finalValue == "") {
  171.                     return;
  172.                 }   
  173.                 // Zavolání funkce na separaci mezer
  174.                 console.log(finalValue.valueOf());
  175.                 finalValue = numberWithSpaces(finalValue);
  176.  
  177.                 return '<div id="castka" style="text-align: right">'
  178.                         + finalValue + " " + "Kč" + '</div>';
  179.             }
  180.         });
  181.         YAHOO.Bubbling.fire("registerRenderer", {
  182.             propertyName : "fato:vysepokutybezna",
  183.             renderer : function attachments_renderer(record, label) {
  184.  
  185.                 var jsNode = record.jsNode, properties = jsNode.properties;
  186.  
  187.                 var finalValue = properties['fato:vysepokutybezna'];
  188.  
  189.                 if(finalValue == null || finalValue == "") {
  190.                     return;
  191.                 }   
  192.                 // Zavolání funkce na separaci mezer
  193.                 console.log(finalValue.valueOf());
  194.                 finalValue = numberWithSpaces(finalValue);
  195.  
  196.                 return '<div id="castka" style="text-align: right">'
  197.                         + finalValue + " " + "Kč" + '</div>';
  198.             }
  199.         });
  200.  
  201.         YAHOO.Bubbling.fire("registerRenderer", {
  202.             propertyName : "fato:upozorneni",
  203.             renderer : function datum_renderer(record, label) {
  204.  
  205.                 var jsNode = record.jsNode, properties = jsNode.properties;
  206.  
  207.                 var finalValue = properties['fato:upozorneni'];
  208.                 if(finalValue == null || finalValue == "") {
  209.                     return;
  210.                 }   
  211.                 var klic = finalValue['iso8601'];
  212.  
  213.                
  214.  
  215.                 var date = new Date(klic);
  216.                 var d = date.getDate();
  217.                 var m = date.getMonth() + 1;
  218.                 var y = date.getFullYear();
  219.  
  220.                 return '<div id="attachments" style="text-align: center">' + d
  221.                         + "." + m + "." + y + '</div>';
  222.             }
  223.         });
  224.         YAHOO.Bubbling.fire("registerRenderer", {
  225.             propertyName : "fato:datumservisu",
  226.             renderer : function datum_renderer(record, label) {
  227.  
  228.                 var jsNode = record.jsNode, properties = jsNode.properties;
  229.  
  230.                 var finalValue = properties['fato:datumservisu'];
  231.                 if(finalValue == null || finalValue == "") {
  232.                     return;
  233.                 }   
  234.                 var klic = finalValue['iso8601'];
  235.  
  236.                
  237.  
  238.                 var date = new Date(klic);
  239.                 var d = date.getDate();
  240.                 var m = date.getMonth() + 1;
  241.                 var y = date.getFullYear();
  242.  
  243.                 return '<div id="attachments" style="text-align: center">' + d
  244.                         + "." + m + "." + y + '</div>';
  245.             }
  246.         });
  247.         YAHOO.Bubbling.fire("registerRenderer", {
  248.             propertyName : "fato:pojistkaauto",
  249.             renderer : function datum_renderer(record, label) {
  250.  
  251.                 var jsNode = record.jsNode, properties = jsNode.properties;
  252.  
  253.                 var finalValue = properties['fato:pojistkaauto'];
  254.                 if(finalValue == null || finalValue == "") {
  255.                     return;
  256.                 }  
  257.                 var klic = finalValue['iso8601'];
  258.  
  259.                  
  260.  
  261.                 var date = new Date(klic);
  262.                 var d = date.getDate();
  263.                 var m = date.getMonth() + 1;
  264.                 var y = date.getFullYear();
  265.  
  266.                 return '<div id="attachments" style="text-align: center">' + d
  267.                         + "." + m + "." + y + '</div>';
  268.             }
  269.         });
  270.         YAHOO.Bubbling.fire("registerRenderer", {
  271.             propertyName : "fato:lekarskaprohlidka",
  272.             renderer : function datum_renderer(record, label) {
  273.  
  274.                 var jsNode = record.jsNode, properties = jsNode.properties;
  275.  
  276.                 var finalValue = properties['fato:lekarskaprohlidka'];
  277.                 if(finalValue == null || finalValue == "") {
  278.                     return;
  279.                 }  
  280.                 var klic = finalValue['iso8601'];
  281.  
  282.                  
  283.  
  284.                 var date = new Date(klic);
  285.                 var d = date.getDate();
  286.                 var m = date.getMonth() + 1;
  287.                 var y = date.getFullYear();
  288.  
  289.                 return '<div id="attachments" style="text-align: center">' + d
  290.                         + "." + m + "." + y + '</div>';
  291.             }
  292.         });
  293.         YAHOO.Bubbling.fire("registerRenderer", {
  294.             propertyName : "fato:skolenibozp",
  295.             renderer : function datum_renderer(record, label) {
  296.  
  297.                 var jsNode = record.jsNode, properties = jsNode.properties;
  298.  
  299.                 var finalValue = properties['fato:skolenibozp'];
  300.  
  301.                 if(finalValue == null || finalValue == "") {
  302.                     return;
  303.                 }  
  304.                 var klic = finalValue['iso8601'];
  305.  
  306.  
  307.                 var date = new Date(klic);
  308.                 var d = date.getDate();
  309.                 var m = date.getMonth() + 1;
  310.                 var y = date.getFullYear();
  311.  
  312.                 return '<div id="attachments" style="text-align: center">' + d
  313.                         + "." + m + "." + y + '</div>';
  314.             }
  315.         });
  316.         YAHOO.Bubbling.fire("registerRenderer", {
  317.             propertyName : "fato:povinneruceni",
  318.             renderer : function datum_renderer(record, label) {
  319.  
  320.                 var jsNode = record.jsNode, properties = jsNode.properties;
  321.  
  322.                 var finalValue = properties['fato:povinneruceni'];
  323.                 if(finalValue == null || finalValue == "") {
  324.                     return;
  325.                 }   
  326.                 var klic = finalValue['iso8601'];
  327.  
  328.                
  329.  
  330.                 var date = new Date(klic);
  331.                 var d = date.getDate();
  332.                 var m = date.getMonth() + 1;
  333.                 var y = date.getFullYear();
  334.  
  335.                 return '<div id="attachments" style="text-align: center">' + d
  336.                         + "." + m + "." + y + '</div>';
  337.             }
  338.         });
  339.         YAHOO.Bubbling.fire("registerRenderer", {
  340.             propertyName : "fato:skoleniridicu",
  341.             renderer : function datum_renderer(record, label) {
  342.  
  343.                 var jsNode = record.jsNode, properties = jsNode.properties;
  344.  
  345.                 var finalValue = properties['fato:skoleniridicu'];
  346.                 if(finalValue == null || finalValue == "") {
  347.                     return;
  348.                 }   
  349.                 var klic = finalValue['iso8601'];
  350.  
  351.                
  352.  
  353.                 var date = new Date(klic);
  354.                 var d = date.getDate();
  355.                 var m = date.getMonth() + 1;
  356.                 var y = date.getFullYear();
  357.  
  358.                 return '<div id="attachments" style="text-align: center">' + d
  359.                         + "." + m + "." + y + '</div>';
  360.             }
  361.         });
  362.  
  363.         return this;
  364.     };
  365.  
  366.     function numberWithSpaces(x) {
  367.         return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); // funkce na
  368.                                                                     // separaci
  369.                                                                     // mezer
  370.     }
  371.     ;
  372.  
  373.     /**
  374.      * Extend from Alfresco.DocumentListViewRenderer
  375.      */
  376.     YAHOO.extend(Alfresco.DocumentListTableViewRenderer,
  377.             Alfresco.DocumentListViewRenderer);
  378.  
  379.     /**
  380.      * @method getConfigWidth
  381.      * @param propColumn
  382.      *            {object}
  383.      */
  384.     Alfresco.DocumentListTableViewRenderer.prototype.getConfigWidth = function(
  385.             propColumn) {
  386.         var width = null;
  387.         var rawWidth = propColumn.width;
  388.         if (rawWidth != null) {
  389.             width = parseInt(rawWidth);
  390.             if (width === NaN) {
  391.                 width = null;
  392.             }
  393.            
  394.         }
  395.         return width;
  396.        
  397.     };
  398.  
  399.     /**
  400.      * @see Alfresco.DocumentListViewRenderer.renderView
  401.      */
  402.     Alfresco.DocumentListTableViewRenderer.prototype.renderView = function DL_SVR_renderView(
  403.             scope, sRequest, oResponse, oPayload) {
  404.         // Add a class to help with CSS selectors...
  405.         var container = Dom.get(scope.id + this.parentElementIdSuffix);
  406.         Dom.addClass(container, 'alf-table');
  407.  
  408.         var viewRendererInstance = this;
  409.  
  410.         scope.widgets.dataTable.set('draggableColumns', false);
  411.  
  412.         var container = Dom.get(scope.id + this.parentElementIdSuffix);
  413.         var oRecordSet = scope.widgets.dataTable.getRecordSet();
  414.         Dom.addClass(container, 'alf-table');
  415.         Dom.removeClass(Dom.get(scope.id + "-table-config-button-container"),
  416.                 'hidden');
  417.  
  418.         // Always hide the fileName column...
  419.         // This has been done due to time-constraints and the issues surrounding
  420.         // the other views (most notably the detailed
  421.         // and simple views) changing the widths of the fileName field. The
  422.         // simplest solution was to just always hide this
  423.         // field and rely on the JSON blob to add in columns that identify the
  424.         // item.
  425.         scope.widgets.dataTable.hideColumn("fileName");
  426.  
  427.         // Not all of the columns are properties, the selector, indicators and
  428.         // actions are not properties and
  429.         // need to be handled by specific configuration defined in the JSON
  430.         // BLOB...
  431.         if (this.additionalJsonConfig != null) {
  432.             // Add/remove actions column as appropriate
  433.             if (this.additionalJsonConfig.actions != null
  434.                     && this.additionalJsonConfig.actions.show == "false") {
  435.                 scope.widgets.dataTable.hideColumn("actions");
  436.             } else {
  437.                 scope.widgets.dataTable.showColumn("actions");
  438.             }
  439.  
  440.             // Add/remove the indicators column...
  441.             if (this.additionalJsonConfig.indicators != null
  442.                     && this.additionalJsonConfig.indicators.show == "false") {
  443.                 scope.widgets.dataTable.hideColumn("status");
  444.             } else {
  445.                 scope.widgets.dataTable.showColumn("status");
  446.             }
  447.  
  448.             // Add/remove the selection box column...
  449.             if (this.additionalJsonConfig.selector != null
  450.                     && this.additionalJsonConfig.selector.show == "false") {
  451.                 scope.widgets.dataTable.hideColumn("nodeRef");
  452.             } else {
  453.                 scope.widgets.dataTable.showColumn("nodeRef");
  454.             }
  455.  
  456.             // Add/remove the thumbnail column...
  457.             if (this.additionalJsonConfig.thumbnail != null
  458.                     && this.additionalJsonConfig.thumbnail.show == "false") {
  459.                 scope.widgets.dataTable.hideColumn("thumbnail");
  460.             } else {
  461.                 scope.widgets.dataTable.showColumn("thumbnail");
  462.             }
  463.  
  464.             // If a JSON blob has been provided then is should define the
  465.             // columns that need to be
  466.             // rendered in the detailed view. Iterate over this configuration
  467.             // and add in the columns
  468.             // defined making use of the data provided...
  469.             if (this.additionalJsonConfig.propertyColumns != null
  470.                     && this.additionalJsonConfig.propertyColumns.length != null) {
  471.                 for (var i = 0; i < this.additionalJsonConfig.propertyColumns.length; i++) {
  472.                     var propColumn = this.additionalJsonConfig.propertyColumns[i];
  473.                     if (propColumn.property != null) {
  474.                         var width = null;
  475.                         var rawWidth = propColumn.width;
  476.                         if (rawWidth != null) {
  477.                             width = parseInt(rawWidth);
  478.                             if (width === NaN) {
  479.                                 width = null;
  480.                             }
  481.                         }
  482.  
  483.                         var columnDef = {
  484.                             key : propColumn.property,
  485.                             label : propColumn.property,
  486.                             formatter : (propColumn.link == "true") ? this
  487.                                     .fnRenderCellLinkProperty() : this
  488.                                     .fnRenderCellProperty(),
  489.                             sortable : false, //ovládání řazení?
  490.                             width : this.getConfigWidth(propColumn)
  491.                         };
  492.                         if (propColumn.label != null) {
  493.                             columnDef.label = scope.msg(propColumn.label);
  494.                         }
  495.                         scope.widgets.dataTable.insertColumn(columnDef);
  496.                     }
  497.                 }
  498.             }
  499.  
  500.             // In order to ensure that the actions column always appears at the
  501.             // end we're goign to remove it and
  502.             // then re-insert it. This is necessary because attempts at
  503.             // inserting the additional columns before
  504.             // the actions column always resulted in unexplainable errors and
  505.             // this was the quickest solution to the
  506.             // problem. It is however only necessary when the actions column is
  507.             // going to be displayed and in
  508.             // actual fact causes more errors if this is attempted after the
  509.             // actions column is hidden...
  510.             if (this.additionalJsonConfig.actions == null
  511.                     || this.additionalJsonConfig.actions.show == "true") {
  512.                 var actionsColumn = scope.widgets.dataTable
  513.                         .removeColumn("actions");
  514.                 scope.widgets.dataTable.insertColumn(actionsColumn);
  515.             }
  516.  
  517.             // Get the current sort data...
  518.             var oSortedBy = scope.widgets.dataTable.get("sortedBy") || {};
  519.             var oState = scope.widgets.dataTable.getState();
  520.  
  521.             YAHOO.util.Dom.setStyle(scope.id + this.parentElementIdSuffix,
  522.                     'display', '');
  523.             scope.widgets.dataTable.onDataReturnInitializeTable.call(
  524.                     scope.widgets.dataTable, sRequest, oResponse, oPayload);
  525.  
  526.             // Reset the sort state...
  527.             scope.widgets.dataTable.set('sortedBy', oState.sortedBy);
  528.         }
  529.     };
  530.  
  531.     /**
  532.      * @see Alfresco.DocumentListViewRenderer.renderCellThumbnail
  533.      */
  534.     Alfresco.DocumentListTableViewRenderer.prototype.renderCellThumbnail = function DL_SVR_renderCellThumbnail(
  535.             scope, elCell, oRecord, oColumn, oData) {
  536.         var record = oRecord.getData(), node = record.jsNode, properties = node.properties, name = record.displayName, isContainer = node.isContainer, isLink = node.isLink, extn = name
  537.                 .substring(name.lastIndexOf(".")), imgId = node.nodeRef.nodeRef; // DD
  538.                                                                                     // added
  539.  
  540.         var containerTarget; // This will only get set if thumbnail
  541.                                 // represents a container
  542.  
  543.         oColumn.width = 16;
  544.  
  545.         if (YAHOO.env.ua.ie > 0) {
  546.             try {
  547.                 scope.widgets.dataTable._elThead.children[0].children[2].children[0].style.width = "16px";
  548.             } catch (e) {
  549.                 // Deliberately swallowing any generated exceptions without
  550.                 // remorse.
  551.             }
  552.  
  553.         }
  554.  
  555.         Dom.setStyle(elCell, "width", oColumn.width + "px");
  556.         Dom.setStyle(elCell.parentNode, "width", oColumn.width + "px");
  557.  
  558.         if (isContainer) {
  559.             elCell.innerHTML = '<span class="folder-small">'
  560.                     + (isLink ? '<span class="link"></span>' : '')
  561.                     + (scope.dragAndDropEnabled ? '<span class="droppable"></span>'
  562.                             : '')
  563.                     + Alfresco.DocumentList.generateFileFolderLinkMarkup(scope,
  564.                             record) + '<img id="' + imgId + '" src="'
  565.                     + this.getFolderIcon(record.node) + '" /></a>';
  566.         } else {
  567.             var id = scope.id + '-preview-' + oRecord.getId();
  568.             elCell.innerHTML = '<span id="'
  569.                     + id
  570.                     + '" class="thumbnail">'
  571.                     + (isLink ? '<span class="link"></span>' : '')
  572.                     + Alfresco.DocumentList.generateFileFolderLinkMarkup(scope,
  573.                             record) + '<img id="' + imgId + '" src="'
  574.                     + Alfresco.DocumentList.generateThumbnailUrl(record)
  575.                     + '" alt="' + extn + '" title="' + $html(name)
  576.                     + '" /></a></span>';
  577.  
  578.             // Preview tooltip
  579.             scope.previewTooltips.push(id);
  580.         }
  581.     };
  582.     /**
  583.      * Default icon resource path string for this view.
  584.      *
  585.      * @returns {String}
  586.      */
  587.     Alfresco.DocumentListTableViewRenderer.prototype.getDefaultFolderIcon = function DL_SVR_getDefaultFolderIcon() {
  588.         return "components/documentlibrary/images/folder-32.png";
  589.     };
  590.     /**
  591.      * Default icon size for this view.
  592.      *
  593.      * @returns {String}
  594.      */
  595.     Alfresco.DocumentListTableViewRenderer.prototype.getIconSize = function DL_SVR_getIconSize() {
  596.         return "32x32";
  597.     };
  598.  
  599.     /**
  600.      * @see Alfresco.DocumentListViewRenderer.destroyView
  601.      */
  602.     Alfresco.DocumentListTableViewRenderer.prototype.destroyView = function DL_SVR_destroyView(
  603.             scope, sRequest, oResponse, oPayload) {
  604.         Alfresco.DocumentListTableViewRenderer.superclass.destroyView.call(
  605.                 this, scope, sRequest, oResponse, oPayload);
  606.  
  607.         // This gets called even before the view has first been created, so we
  608.         // need to ensure we have the original
  609.         // set of columns so that they can be restored for the benefit of other
  610.         // views...
  611.         if (!this.originalColumnDefinitions) {
  612.             // Save the originalColumnDefinitions
  613.             this.originalColumnDefinitions = [];
  614.             var columnDefinitions = scope.widgets.dataTable.getColumnSet()
  615.                     .getDefinitions();
  616.             for (var i = 0; i < columnDefinitions.length; i++) {
  617.                 this.originalColumnDefinitions[i] = columnDefinitions[i];
  618.             }
  619.         }
  620.  
  621.         var container = Dom.get(scope.id + this.parentElementIdSuffix);
  622.         Dom.removeClass(container, 'alf-table');
  623.         Dom.addClass(Dom.get(scope.id + "-table-config-button-container"),
  624.                 'hidden');
  625.  
  626.         // Rebuild the original columns...
  627.         if (this.originalColumnDefinitions) {
  628.             // Ensure that all the "core" columns are displayed again (these
  629.             // columns are the ones that
  630.             // were defined by the original detailed view and need to be in
  631.             // place for the other views
  632.             // to continue to work...
  633.             scope.widgets.dataTable.showColumn("nodeRef");
  634.             scope.widgets.dataTable.showColumn("status");
  635.             scope.widgets.dataTable.showColumn("thumbnail");
  636.             scope.widgets.dataTable.showColumn("fileName");
  637.             scope.widgets.dataTable.showColumn("actions");
  638.  
  639.             // Remove all the current columns (except for those core columns)...
  640.             var currentColumnDefinitions = [];
  641.             var currentColumnDefinitionsCall = scope.widgets.dataTable
  642.                     .getColumnSet().getDefinitions();
  643.  
  644.             // currentColumnDefinitionsCall changes during iteration
  645.             for (var i = currentColumnDefinitionsCall.length - 1; i >= 0; i--) {
  646.                 switch (currentColumnDefinitionsCall[i].key) {
  647.                 case "nodeRef":
  648.                 case "status":
  649.                 case "thumbnail":
  650.                 case "fileName":
  651.                 case "actions":
  652.                     break;
  653.                 default:
  654.                     scope.widgets.dataTable
  655.                             .removeColumn(currentColumnDefinitionsCall[i].key);
  656.                 }
  657.             }
  658.  
  659.             // Add back in any of the original columns that have since been
  660.             // deleted (typically this
  661.             // won't actually add anything back)...
  662.             for (var i = 0; i < this.originalColumnDefinitions.length; i++) {
  663.                 switch (this.originalColumnDefinitions[i].key) {
  664.                 case "nodeRef":
  665.                 case "status":
  666.                 case "thumbnail":
  667.                 case "fileName":
  668.                 case "actions":
  669.                     break;
  670.                 default:
  671.                     scope.widgets.dataTable
  672.                             .insertColumn(this.originalColumnDefinitions[i]);
  673.                 }
  674.             }
  675.         }
  676.     };
  677.  
  678.     /**
  679.      * Generic string custom datacell formatter
  680.      *
  681.      * @method renderCellGenericString
  682.      * @param elCell
  683.      *            {object}
  684.      * @param oRecord
  685.      *            {object}
  686.      * @param oColumn
  687.      *            {object}
  688.      * @param oData
  689.      *            {object|string}
  690.      */
  691.     Alfresco.DocumentListTableViewRenderer.prototype.renderCellGenericString = function DL_SVR_renderCellGenericString(
  692.             elCell, oRecord, oColumn, oData) {
  693.         var record = oRecord.getData(), node = record.jsNode, properties = node.properties, propertyValue = properties[oColumn.field];
  694.         if (propertyValue != null) {
  695.             elCell.innerHTML = '<span class="alf-generic-property">'
  696.                     + propertyValue + '</span>';
  697.         }
  698.     };
  699.  
  700.     /**
  701.      * Uses a defined metadata 'line' template and renderer as a custom datacell
  702.      * formatter
  703.      *
  704.      * @method renderCellMetadataLineRenderer
  705.      * @param scope
  706.      *            {object} The DocumentList object
  707.      * @param elCell
  708.      *            {object}
  709.      * @param oRecord
  710.      *            {object}
  711.      * @param oColumn
  712.      *            {object}
  713.      * @param oData
  714.      *            {object|string}
  715.      * @param line
  716.      *            {object} the metadata 'line' object
  717.      */
  718.     Alfresco.DocumentListTableViewRenderer.prototype.renderCellMetadataLineRenderer = function DL_SVR_renderCellMetadataLineRenderer(
  719.             scope, elCell, oRecord, oColumn, oData, line) {
  720.         var desc = "", i, j, record = oRecord.getData(), jsNode = record.jsNode;
  721.  
  722.         var fnRenderTemplate = function fnRenderTemplate_substitute(p_key,
  723.                 p_value, p_meta) {
  724.             var label = (p_meta !== null ? '<em>' + scope.msg(p_meta)
  725.                     + '</em>: ' : ''), value = "";
  726.  
  727.             // render value from properties or custom renderer
  728.             if (scope.renderers.hasOwnProperty(p_key)
  729.                     && typeof scope.renderers[p_key] === "function") {
  730.                 value = scope.renderers[p_key].call(scope, record, label);
  731.             } else {
  732.                 if (jsNode.hasProperty(p_key)) {
  733.                     value = '<span class="item">' + label
  734.                             + $html(jsNode.properties[p_key]) + '</span>';
  735.                 }
  736.             }
  737.  
  738.             return value;
  739.         };
  740.  
  741.         var html;
  742.         if (!$isValueSet(line.view) || line.view == this.metadataLineViewName) {
  743.             html = YAHOO.lang.substitute(line.template, scope.renderers,
  744.                     fnRenderTemplate);
  745.             if ($isValueSet(html)) {
  746.                 desc += '<div class="detail">' + html + '</div>';
  747.             }
  748.         }
  749.  
  750.         elCell.innerHTML = desc;
  751.     };
  752.  
  753. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement