From 9e2e2a3438efaac1f4b332eb2735849520719679 Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 11 Jun 2020 03:02:38 +0900 Subject: [PATCH] add delete button and fix some variable issues --- .../dashboard/plugins/repositories.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js index 7e8b711b37..cfb71284b6 100644 --- a/src/controllers/dashboard/plugins/repositories.js +++ b/src/controllers/dashboard/plugins/repositories.js @@ -5,19 +5,19 @@ import dialogHelper from 'dialogHelper'; import 'emby-button'; import 'emby-checkbox'; import 'emby-select'; -import 'cardStyle'; import 'formDialogStyle'; +import 'listViewStyle'; let repositories = []; function reloadList(page) { loading.show(); - ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(repositories => { - this.repositories = repositories; + ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => { + repositories = list; populateList({ listElement: page.querySelector('#repositories'), noneElement: page.querySelector('#none'), - repositories: this.repositories + repositories: repositories }); }).catch(error => { page.querySelector('#none').classList.remove('hide'); @@ -57,12 +57,15 @@ function populateList(options) { function getRepositoryHtml(repository) { var html = ''; - html += ``; + html += '
'; html += ''; html += ''; + html += '
'; + html += ``; + html += ''; return html; } @@ -84,6 +87,13 @@ export default function(view, params) { view.addEventListener('viewshow', function () { libraryMenu.setTabs('plugins', 2, getTabs); reloadList(this); + + var save = this; + $('#repositories', view).on('click', '.btnDelete', function() { + repositories = repositories.splice(repositories.indexOf(this.id), 1); + saveList(); + reloadList(save); + }); }); view.querySelector('.btnNewRepository').addEventListener('click', () => { @@ -100,7 +110,7 @@ export default function(view, params) { html += ''; html += `

${globalize.translate('HeaderNewRepository')}

`; html += ''; - html += '
'; + html += ''; html += '
'; html += ``; html += `
${globalize.translate('LabelRepositoryNameHelp')}
`; @@ -118,7 +128,7 @@ export default function(view, params) { dialogHelper.close(dialog); }); - dialog.querySelector('.button-submit').addEventListener('click', () => { + dialog.querySelector('.newPluginForm').addEventListener('submit', () => { repositories.push({ Name: dialog.querySelector('#txtRepositoryName').value, Url: dialog.querySelector('#txtRepositoryUrl').value,