Sha256: c92720fc54ec5fe79a19921ba8d4ab685f6b287433e97e73c1430457695d1835

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

import RelationshipsControl from 'sufia/relationships/control'
import SaveWorkControl from 'sufia/save_work/save_work_control'
import AdminSetWidget from 'sufia/editor/admin_set_widget'

export default class {
  constructor(element) {
    this.element = element
    this.adminSetWidget = new AdminSetWidget(element.find('select[id$="_admin_set_id"]'))
    this.sharingTabElement = $('#tab-share')

    this.sharingTab()
    this.relationshipsControl()
    this.saveWorkControl()
    this.saveWorkFixed()
  }

  // Display the sharing tab if they select an admin set that permits sharing
  sharingTab() {
    if(this.adminSetWidget && !this.adminSetWidget.isEmpty()) {
      this.adminSetWidget.on('change', (data) => this.sharingTabVisiblity(data))
      this.sharingTabVisiblity(this.adminSetWidget.isSharing())
    }
  }

  sharingTabVisiblity(visible) {
      if (visible)
         this.sharingTabElement.removeClass('hidden')
      else
         this.sharingTabElement.addClass('hidden')
  }

  relationshipsControl() {
      new RelationshipsControl(this.element.find('[data-behavior="child-relationships"]'),
                               'work_members_attributes',
                               'tmpl-child-work')
  }

  saveWorkControl() {
      new SaveWorkControl(this.element.find("#form-progress"), this.adminSetWidget)
  }

  saveWorkFixed() {
      // Setting test to false to skip native and go right to polyfill
      FixedSticky.tests.sticky = false
      this.element.find('#savewidget').fixedsticky()
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sufia-7.4.1 app/assets/javascripts/sufia/editor.es6
sufia-7.4.0 app/assets/javascripts/sufia/editor.es6
sufia-7.3.1 app/assets/javascripts/sufia/editor.es6
sufia-7.3.0 app/assets/javascripts/sufia/editor.es6