Compare commits
1 Commits
dev-landin
...
dev-downlo
| Author | SHA1 | Date | |
|---|---|---|---|
| a1a38cb74c |
@@ -21,7 +21,7 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static outlets = ['movie-results', 'tv-results']
|
static outlets = ['movie-results', 'tv-results']
|
||||||
static targets = ['resolution', 'codec', 'language', 'provider', 'season', 'selectAll']
|
static targets = ['resolution', 'codec', 'language', 'provider', 'season', 'selectAll', 'downloadSelected']
|
||||||
static values = {
|
static values = {
|
||||||
'media-type': String,
|
'media-type': String,
|
||||||
'episodes': Array,
|
'episodes': Array,
|
||||||
@@ -166,11 +166,23 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uncheckSelectAllBtn() {
|
uncheckSelectAllBtn() {
|
||||||
console.log('hurr');
|
|
||||||
this.selectAllTarget.checked = false;
|
this.selectAllTarget.checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectAllEpisodes() {
|
selectAllEpisodes() {
|
||||||
this.tvResultsOutlets.forEach((episode) => episode.selectEpisodeForDownload());
|
this.tvResultsOutlets.forEach((episode) => {
|
||||||
|
if (episode.isActive()) {
|
||||||
|
episode.selectEpisodeForDownload()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadSelectedEpisodes() {
|
||||||
|
this.tvResultsOutlets.forEach(episode => {
|
||||||
|
if (episode.isActive() && episode.isSelected()) {
|
||||||
|
episode.download();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.selectAllTarget.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ export default class extends Controller {
|
|||||||
return this.activeValue;
|
return this.activeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isSelected() {
|
||||||
|
return this.episodeSelectorTarget.checked;
|
||||||
|
}
|
||||||
|
|
||||||
selectEpisodeForDownload() {
|
selectEpisodeForDownload() {
|
||||||
if (true === this.isActive() && this.episodeSelectorTarget.disabled === false) {
|
if (true === this.isActive() && this.episodeSelectorTarget.disabled === false) {
|
||||||
this.episodeSelectorTarget.checked = !this.episodeSelectorTarget.checked;
|
this.episodeSelectorTarget.checked = !this.episodeSelectorTarget.checked;
|
||||||
@@ -71,4 +75,17 @@ export default class extends Controller {
|
|||||||
toggleList() {
|
toggleList() {
|
||||||
this.listTarget.classList.toggle('hidden');
|
this.listTarget.classList.toggle('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download() {
|
||||||
|
this.options.forEach(option => {
|
||||||
|
const optionSelector = option.querySelector('input[type="checkbox"]');
|
||||||
|
if (true === optionSelector.checked) {
|
||||||
|
const downloadBtn = option.querySelector('button.download-btn');
|
||||||
|
const downloadBtnController = this.application.getControllerForElementAndIdentifier(downloadBtn, 'download-button');
|
||||||
|
downloadBtnController.download();
|
||||||
|
optionSelector.checked = false;
|
||||||
|
this.episodeSelectorTarget.checked = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,10 @@
|
|||||||
|
|
||||||
{% if results.media.mediaType == "tvshows" %}
|
{% if results.media.mediaType == "tvshows" %}
|
||||||
<div class="flex flex-row gap-2 justify-end px-8">
|
<div class="flex flex-row gap-2 justify-end px-8">
|
||||||
<button class="px-1.5 py-1 bg-green-600 rounded-md text-sm">Download Selected</button>
|
<button class="px-1.5 py-1 bg-green-600 rounded-md text-sm"
|
||||||
|
{{ stimulus_target('result_filter', 'downloadSelected') }}
|
||||||
|
{{ stimulus_action('result_filter', 'downloadSelectedEpisodes', 'click') }}
|
||||||
|
>Download Selected</button>
|
||||||
<input type="checkbox" name="selectAll" id="selectAll"
|
<input type="checkbox" name="selectAll" id="selectAll"
|
||||||
{{ stimulus_target('result_filter', 'selectAll') }}
|
{{ stimulus_target('result_filter', 'selectAll') }}
|
||||||
{{ stimulus_action('result_filter', 'selectAllEpisodes', 'change') }}
|
{{ stimulus_action('result_filter', 'selectAllEpisodes', 'change') }}
|
||||||
|
|||||||
Reference in New Issue
Block a user