You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
import ApplicationController from './application_controller' |
|
export default class extends ApplicationController { |
|
connect () { |
|
super.connect() |
|
} |
|
|
|
loadSubjectsAccordion () { |
|
var $this = this, params = { per_page: 200 }, parent_id = $this.element.dataset["subjectParentId"], |
|
opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"], |
|
accordionFor: $this.element.dataset["accordionFor"] } |
|
|
|
if (parent_id !== null && parent_id !== undefined && parent_id !== "") { |
|
params.parent_id = parent_id |
|
} else { |
|
params.is_root = true |
|
} |
|
|
|
if ($(opts.accordionTarget).find(".accordion-flash").length === 0) { |
|
$.get("/api/subjects.json", params, function (search_results, status) { |
|
if (status === "success") { |
|
if (search_results.length > 5) { |
|
$('.offcanvas-contents').find(".accordion-body").addClass('for-body-grid'); |
|
} |
|
$this.stimulate("SubjectsReflex#render_subjects_accordion", search_results, opts) |
|
} |
|
}) |
|
} |
|
} |
|
}
|
|
|