fix: loading of the config pages.
This commit is contained in:
parent
aa6fed146d
commit
9ca1712b5d
2 changed files with 50 additions and 42 deletions
|
@ -3,7 +3,7 @@ var COLLECTIONS = [
|
|||
{
|
||||
Id: 'My New Smartcollection',
|
||||
Name: 'My New Smartcollection',
|
||||
Program: '(is-favourite)',
|
||||
Program: 'nil',
|
||||
SortProgram: '(begin *items*)',
|
||||
CollectionId: '00000000000000000000000000000000',
|
||||
Enabled: true,
|
||||
|
@ -73,17 +73,29 @@ ApiClient.setSmartCollection = function (c) {
|
|||
data: JSON.stringify(c),
|
||||
});
|
||||
}
|
||||
|
||||
function initial_load(selectedId) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getSmartCollections().then(function (collections) {
|
||||
COLLECTIONS = [COLLECTIONS[0]].concat(collections);
|
||||
const selection = document.querySelector('#SmartcollectionSelection');
|
||||
fillCollectionSelect(COLLECTIONS);
|
||||
if (selectedId === null) {
|
||||
selection.selectedIndex = 0;
|
||||
} else {
|
||||
selection.selectedIndex = COLLECTIONS.map(x => x.Id).indexOf(selectedId);
|
||||
}
|
||||
fillForm(COLLECTIONS[selection.selectedIndex]);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
document.querySelector('#SmartCollectionConfigPage')
|
||||
.addEventListener('viewshow', function() {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getSmartCollections().then(function (collections) {
|
||||
COLLECTIONS = [COLLECTIONS[0]].concat(collections);
|
||||
const selection = document.querySelector('#SmartcollectionSelection');
|
||||
fillCollectionSelect(COLLECTIONS);
|
||||
fillForm(COLLECTIONS[selection.selectedIndex]);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
initial_load(null);
|
||||
});
|
||||
|
||||
document.querySelector('#SmartCollectionConfigPage')
|
||||
.addEventListener('pageshow', function() {
|
||||
initial_load(null);
|
||||
});
|
||||
|
||||
document.querySelector('#SmartcollectionSelection')
|
||||
|
@ -96,16 +108,9 @@ document.querySelector('#SmartCollectionConfigForm')
|
|||
.addEventListener('submit', function (e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
const selection = document.querySelector('#SmartcollectionSelection');
|
||||
const selectedid = COLLECTIONS[selection.selectedIndex].Id;
|
||||
const selectedId = COLLECTIONS[selection.selectedIndex].Id;
|
||||
ApiClient.setSmartCollection(jsonFromForm(COLLECTIONS[selection.selectedIndex].CollectionId)).then(function () {
|
||||
ApiClient.getSmartCollections().then(function (collections) {
|
||||
COLLECTIONS = [COLLECTIONS[0]].concat(collections);
|
||||
fillCollectionSelect(COLLECTIONS);
|
||||
const idx = COLLECTIONS.map(x => x.Id).indexOf(selectedid);
|
||||
selection.selectedIndex = idx;
|
||||
fillForm(COLLECTIONS[selection.selectedIndex]);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
initial_load(selectedId);
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
|
|
|
@ -97,19 +97,32 @@ ApiClient.setSmartPlaylist = function (p) {
|
|||
});
|
||||
}
|
||||
|
||||
function initial_load(selectedId) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getSmartPlaylists().then(function (playlists) {
|
||||
PLAYLISTS = [PLAYLISTS[0]].concat(playlists);
|
||||
ApiClient.getUsers().then(function (users) {
|
||||
USERS = users;
|
||||
const selection = document.querySelector('#SmartplaylistSelection');
|
||||
fillPlaylistSelect(PLAYLISTS);
|
||||
if (selectedId === null) {
|
||||
selection.selectedIndex = 0;
|
||||
} else {
|
||||
selection.selectedIndex = PLAYLISTS.map(x => x.Id).indexOf(selectedId);
|
||||
}
|
||||
fillForm(PLAYLISTS[selection.selectedIndex], USERS);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelector('#SmartPlaylistConfigPage')
|
||||
.addEventListener('viewshow', function() {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getSmartPlaylists().then(function (playlists) {
|
||||
PLAYLISTS = [PLAYLISTS[0]].concat(playlists);
|
||||
ApiClient.getUsers().then(function (users) {
|
||||
USERS = users;
|
||||
const selection = document.querySelector('#SmartplaylistSelection');
|
||||
fillPlaylistSelect(PLAYLISTS);
|
||||
fillForm(PLAYLISTS[selection.selectedIndex], USERS);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
initial_load(null);
|
||||
});
|
||||
document.querySelector('#SmartPlaylistConfigPage')
|
||||
.addEventListener('pageshow', function() {
|
||||
initial_load(null);
|
||||
});
|
||||
|
||||
document.querySelector('#SmartplaylistSelection')
|
||||
|
@ -122,19 +135,9 @@ document.querySelector('#SmartPlaylistConfigForm')
|
|||
.addEventListener('submit', function (e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
const selection = document.querySelector('#SmartplaylistSelection');
|
||||
const selectedid = PLAYLISTS[selection.selectedIndex].Id;
|
||||
const selectedId = PLAYLISTS[selection.selectedIndex].Id;
|
||||
ApiClient.setSmartPlaylist(jsonFromForm()).then(function () {
|
||||
ApiClient.getSmartPlaylists().then(function (playlists) {
|
||||
PLAYLISTS = [PLAYLISTS[0]].concat(playlists);
|
||||
ApiClient.getUsers().then(function (users) {
|
||||
USERS = users;
|
||||
fillPlaylistSelect(PLAYLISTS);
|
||||
const idx = PLAYLISTS.map(x => x.Id).indexOf(selectedid);
|
||||
selection.selectedIndex = idx;
|
||||
fillForm(PLAYLISTS[selection.selectedIndex], USERS);
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
initial_load(selectedId);
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue