Sha256: 5ffc6be210e101a2a91b32ac49c958110d28d3fe5cda5f163e050f356dce52d3

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

import { RemoteSelect } from "alchemy_admin/components/remote_select"

class PageSelect extends RemoteSelect {
  get pageId() {
    return this.selection ? JSON.parse(this.selection)["id"] : undefined
  }

  _searchQuery(term, page) {
    return {
      q: {
        name_cont: term,
        ...JSON.parse(this.queryParams)
      },
      page: page
    }
  }

  _parseResponse(response) {
    const meta = response.meta
    return {
      results: response.pages,
      more: meta.page * meta.per_page < meta.total_count
    }
  }

  /**
   * result which is visible if a page was selected
   * @param {object} page
   * @returns {string}
   * @private
   */
  _renderResult(page) {
    return page.text || page.name
  }

  /**
   * html template for each list entry
   * @param {object} page
   * @param {string} term
   * @returns {string}
   * @private
   */
  _renderListEntry(page, term) {
    return `
      <div class="page-select--page">
        <div class="page-select--top">
          <alchemy-icon name="file-3"></alchemy-icon>
          <span class="page-select--page-name">${this._hightlightTerm(page.name, term)}</span>
          <span class="page-select--site-name">${page.site.name}</span>
        </div>
        <div class="page-select--bottom">
          <span class="page-select--page-urlname">${page.url_path}</span>
          <span class="page-select--language-code">${page.language_code}</span>
        </div>
      </div>
    `
  }
}

customElements.define("alchemy-page-select", PageSelect)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.3.3 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.3.2 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.7 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.3.1 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.3.0 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.6 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.5 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.4 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.3 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.2 app/javascript/alchemy_admin/components/page_select.js
alchemy_cms-7.2.1 app/javascript/alchemy_admin/components/page_select.js