Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.70 KB | None | 0 0
  1. <link rel="import" href="../polymer/polymer-element.html">
  2. <link rel="import" href="../imgp-components/imgp-notifier-mixin.html">
  3.  
  4. <link rel="import" href="shared-styles/shared-styles.html">
  5. <link rel="import" href="section-tab.html">
  6.  
  7. <link rel="import" href="shared-components-mixin.html">
  8. <link rel="import" href="../imgp-commons/mustache.html">
  9. <link rel="import" href="../paper-icon-button/paper-icon-button.html">
  10. <link rel="import" href="../iron-icon/iron-icon.html">
  11. <link rel="import" href="../iron-icons/iron-icons.html">
  12.  
  13. <dom-module id="list-view">
  14.     <template>
  15.         <style include='shared-styles'>
  16.             :host {
  17.                 display: block
  18.             }
  19.  
  20.             .wrapper__scroll {
  21.                 overflow-y: scroll;
  22.                 display: grid;
  23.                 grid-auto-rows: 1fr;
  24.                 grid-gap: 1em;
  25.                 padding: 1em;
  26.             }
  27.  
  28.             .wrapper__scroll--columns1 {
  29.                 grid-template-columns: repeat(1, 1fr);
  30.             }
  31.  
  32.             .wrapper__scroll--columns2 {
  33.                 grid-template-columns: repeat(2, 1fr);
  34.             }
  35.  
  36.             .wrapper__scroll--columns3 {
  37.                 grid-template-columns: repeat(3, 1fr);
  38.             }
  39.        
  40.            
  41.  
  42.             .item--view {
  43.                 display: flex;
  44.                 flex-direction: column;
  45.                 align-items: flex-start;
  46.                 padding: 0.6em;
  47.             }
  48.  
  49.             .item--view>p {
  50.                 margin: 0;
  51.             }
  52.  
  53.             .wrapper__action-buttons {
  54.                 justify-self: flex-end;
  55.                 align-self: flex-start;
  56.             }
  57.  
  58.             paper-icon-button:focus {
  59.                 background-color: rgba(28, 45, 14, 0.12);
  60.                 border-radius: 50%;
  61.             }
  62.  
  63.         </style>
  64.  
  65.  
  66.         <!-- <template is="dom-if" if="{{document.length}}" restamp> -->
  67.         <!-- <h3>Lista podmiotów związanych z umową</h3>
  68.        <paper-item>PODMIOT</paper-item> -->
  69.         <div class$="wrapper__scroll [[_changeNumberOfColumns(columns)]]">
  70.             <template is="dom-repeat" items="{{list}}" as="item" indexAs="index">
  71.                 <!-- <div class="wrapper__icons-value"> -->
  72.         </div>
  73.         <div id="innanazwa">
  74.             <div class="item--view" inner-h-t-m-l="[[_getValue(item)]]"></div>
  75.             <div class="wrapper__action-buttons">
  76.                 <template is="dom-repeat" items="{{actions}}" as="action">
  77.                     <paper-icon-button data-item="[[item]]" id="[[action.id]]" id$="_addHighLight[[index]]"
  78.                        icon="[[action.icon]]" alt="[[action.alt]]"></paper-icon-button>
  79.                 </template>
  80.             </div>
  81.         </div>
  82.     </template>
  83.     </div>
  84.     <!-- </template> -->
  85.  
  86.     </template>
  87.  
  88.     <script>
  89.  
  90.         /**
  91.          * `list-view` Description
  92.          *
  93.          * @summary ShortDescription.
  94.          * @customElement
  95.          * @polymer
  96.          * @extends {Polymer.Element}
  97.          */
  98.         class ListView extends GP.SharedComponentsMixin(GP.ImgpNotifierMixin(Polymer.Element)) {
  99.  
  100.             /**
  101.              * String providing the tag name to register the element under.
  102.              */
  103.             static get is() {
  104.                 return 'list-view';
  105.             }
  106.  
  107.             /**
  108.              * Object describing property-related metadata used by Polymer features
  109.              */
  110.             static get properties() {
  111.                 return {
  112.                     dictionary: {
  113.                         type: Object,
  114.                         notify: true,
  115.                     },
  116.                     list: {
  117.                         type: Array,
  118.                         notify: true,
  119.                     },
  120.                     template: {
  121.                         type: Array,
  122.                         notify: true,
  123.                         value: "<p>{{{key}}}:&nbsp;<strong>{{{value}}}&nbsp;</strong></p>"
  124.                     },
  125.                     actions: {
  126.                         type: Array,
  127.                         notify: true,
  128.                     },
  129.                     columns: {
  130.                         type: Number,
  131.                         notify: true,
  132.                     },
  133.                     tapStatus: {
  134.                         type: String,
  135.                         notify: true,
  136.                     }
  137.  
  138.                 };
  139.             }
  140.  
  141.             _getValue(item) {
  142.                 let x = '';
  143.                 // if (Object.keys(this.dictionary).length != 2) console.warn("list-view parametr dicionary został niepoprawnie zadeklarowany")
  144.                 Object.keys(this.dictionary).forEach(k => {
  145.                     if (!this.dictionary[k].noShowEmptyValue) {
  146.                         if (this.dictionary[k].label) {
  147.                             x += this._displayList(this.dictionary[k].label, item.attributes[k])
  148.                         } else {
  149.                             x += this._displayList(this.dictionary[k], item.attributes[k])
  150.                         }
  151.                     } else {
  152.                         if (item.attributes[k]) {
  153.                             if (this.dictionary[k].label) {
  154.                                 x += this._displayList(this.dictionary[k].label, item.attributes[k])
  155.                             } else {
  156.                                 x += this._displayList(this.dictionary[k], item.attributes[k])
  157.                             }
  158.                         }
  159.                     }
  160.                 })
  161.                 return x;
  162.             }
  163.  
  164.             _displayList(key, value) {
  165.                 return Mustache.render(this.template, { key, value });
  166.             }
  167.  
  168.             _actionChanged(e) {
  169.                 this.dispatchEvent(new CustomEvent("action-changed", { detail: { index: e.model.index, item: this.list[e.model.index], action: e.model.action.id } }));
  170.             }      
  171.            
  172.             _changeNumberOfColumns(columns) {
  173.                 if (this.columns >= 1) {
  174.                     return `wrapper__scroll--columns${this.columns}`
  175.                 }
  176.             }
  177.  
  178.             /**
  179.              * Use for one-time configuration of your component after local DOM is initialized.
  180.              */
  181.             ready() {
  182.                 super.ready();
  183.                 super.connectedCallback();
  184.  
  185.                 Polymer.RenderStatus.afterNextRender(this, function () {
  186.  
  187.  
  188.                 });
  189.             }
  190.  
  191.             _changeNumberOfColumns(columns) {
  192.                 if (this.columns >= 1) {
  193.                     return `wrapper__scroll--columns${this.columns}`
  194.                 }
  195.             }
  196.  
  197.         }
  198.  
  199.         window.customElements.define(ListView.is, ListView);
  200.     </script>
  201. </dom-module>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement