Sha256: b4cf429faa8277bbf71036cdfcdcfcae198d08abb9c721884f6101e24254730d

Contents?: true

Size: 720 Bytes

Versions: 44

Compression:

Stored size: 720 Bytes

Contents

export default class AutoLabelByPositionComponent {
  constructor(options = {}) {
    this.listSelector = options.listSelector;
    this.labelSelector = options.labelSelector;
    this.onPositionComputed = options.onPositionComputed;

    this.run();
  }

  run() {
    const $list = $(this.listSelector);

    $list.each((idx, el) => {
      const $label = $(el).find(this.labelSelector);
      const labelContent = $label.html();

      if (labelContent.match(/#(\d+)/)) {
        $label.html(labelContent.replace(/#(\d+)/, `#${idx + 1}`));
      } else {
        $label.html(`${labelContent} #${idx + 1}`);
      }

      if (this.onPositionComputed) {
        this.onPositionComputed(el, idx);
      }
    });
  }
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.4 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.27.9 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.29.0 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.3 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.27.8 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.29.0.rc4 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.29.0.rc3 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.29.0.rc2 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.29.0.rc1 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.2 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.27.7 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.1 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.27.6 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.26.10 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.26.9 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.0 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.27.5 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.0.rc5 app/packs/src/decidim/admin/auto_label_by_position.component.js
decidim-admin-0.28.0.rc4 app/packs/src/decidim/admin/auto_label_by_position.component.js