Merge pull request #435 from grafixeyehero/deletehelper

Change primary highlight for delete confirmation dialog
This commit is contained in:
Joshua M. Boniface 2019-09-19 11:27:08 -04:00 committed by GitHub
commit ff68a0d550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 161 additions and 74 deletions

View File

@ -18,13 +18,13 @@ define(['dialog', 'globalize'], function (dialog, globalize) {
items.push({
name: options.cancelText || globalize.translate('ButtonCancel'),
id: 'cancel',
type: options.primary === 'cancel' ? 'submit' : 'cancel'
type: 'cancel'
});
items.push({
name: options.confirmText || globalize.translate('ButtonOk'),
id: 'ok',
type: options.primary === 'cancel' ? 'cancel' : 'submit'
type: options.primary === 'delete' ? 'delete' : 'submit'
});
options.buttons = items;

View File

@ -27,7 +27,7 @@ define(['connectionManager', 'confirm', 'appRouter', 'globalize'], function (con
title: title,
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'cancel'
primary: 'delete'
}).then(function () {

View File

@ -203,7 +203,7 @@ define(['dialogHelper', 'connectionManager', 'loading', 'dom', 'layoutManager',
text: globalize.translate('ConfirmDeleteImage'),
confirmText: globalize.translate('Delete'),
primary: 'cancel'
primary: 'delete'
}).then(afterConfirm);
});

View File

@ -59,7 +59,7 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
title: Globalize.translate("HeaderRemoveMediaLocation"),
text: Globalize.translate("MessageConfirmRemoveMediaLocation"),
confirmText: Globalize.translate("ButtonDelete"),
primary: "cancel"
primary: "delete"
}).then(function() {
var refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function() {

View File

@ -37,7 +37,7 @@ define(['globalize', 'loading', 'connectionManager'], function (globalize, loadi
confirm({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'cancel',
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
@ -62,7 +62,7 @@ define(['globalize', 'loading', 'connectionManager'], function (globalize, loadi
confirm({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'cancel',
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')

View File

@ -74,7 +74,7 @@ define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings',
title: globalize.translate('ConfirmDeletion'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'cancel'
primary: 'delete'
}).then(function () {

View File

@ -101,6 +101,11 @@ html {
background: #0cb0e8
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -88,6 +88,11 @@ html {
color: #fff
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -69,6 +69,11 @@ html {
color: #fff
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -69,6 +69,11 @@ html {
color: #fff
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -84,6 +84,11 @@ html {
background: #0cb0e8
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -143,6 +143,11 @@ a[data-role=button] {
background: #ff77f1
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
#btnResetPassword,
.btnForgotPassword,
.btnCancel,

View File

@ -94,6 +94,11 @@ html {
color: #fff
}
.button-delete {
background: rgb(247, 0, 0);
color: rgba(255, 255, 255, .87)
}
.checkboxLabel {
color: inherit
}

View File

@ -697,7 +697,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
title: globalize.translate("HeaderRestart"),
text: globalize.translate("MessageConfirmRestart"),
confirmText: globalize.translate("ButtonRestart"),
primary: "cancel"
primary: "delete"
}).then(function () {
var page = dom.parentWithClass(btn, "page");
buttonEnabled(page.querySelector("#btnRestartServer"), false);
@ -712,7 +712,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
title: globalize.translate("HeaderShutdown"),
text: globalize.translate("MessageConfirmShutdown"),
confirmText: globalize.translate("ButtonShutdown"),
primary: "cancel"
primary: "delete"
}).then(function () {
var page = dom.parentWithClass(btn, "page");
buttonEnabled(page.querySelector("#btnRestartServer"), false);

View File

@ -12,7 +12,7 @@ define(["loading", "dom", "libraryMenu", "globalize", "scripts/imagehelper", "hu
text: msg,
title: globalize.translate("HeaderDeleteDevice"),
confirmText: globalize.translate("ButtonDelete"),
primary: "cancel"
primary: "delete"
}).then(function() {
loading.show(), ApiClient.ajax({
type: "DELETE",

View File

@ -7,7 +7,7 @@ define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-button"
confirm({
title: globalize.translate("UninstallPluginHeader"),
text: msg,
primary: "cancel",
primary: "delete",
confirmText: globalize.translate("UninstallPluginHeader")
}).then(function() {
loading.show();

View File

@ -1,48 +1,61 @@
define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "globalize", "dom", "indicators", "scripts/imagehelper", "cardStyle", "emby-itemrefreshindicator"], function($, appHost, taskButton, loading, libraryMenu, globalize, dom, indicators, imageHelper) {
define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "globalize", "dom", "indicators", "scripts/imagehelper", "cardStyle", "emby-itemrefreshindicator"], function ($, appHost, taskButton, loading, libraryMenu, globalize, dom, indicators, imageHelper) {
"use strict";
function addVirtualFolder(page) {
require(["medialibrarycreator"], function(medialibrarycreator) {
(new medialibrarycreator).show({
collectionTypeOptions: getCollectionTypeOptions().filter(function(f) {
require(["medialibrarycreator"], function (medialibrarycreator) {
new medialibrarycreator().show({
collectionTypeOptions: getCollectionTypeOptions().filter(function (f) {
return !f.hidden;
}),
refresh: shouldRefreshLibraryAfterChanges(page)
}).then(function(hasChanges) {
hasChanges && reloadLibrary(page);
})
})
}).then(function (hasChanges) {
if (hasChanges) {
reloadLibrary(page);
}
});
});
}
function editVirtualFolder(page, virtualFolder) {
require(["medialibraryeditor"], function(medialibraryeditor) {
(new medialibraryeditor).show({
require(["medialibraryeditor"], function (medialibraryeditor) {
new medialibraryeditor().show({
refresh: shouldRefreshLibraryAfterChanges(page),
library: virtualFolder
}).then(function(hasChanges) {
hasChanges && reloadLibrary(page);
})
})
}).then(function (hasChanges) {
if (hasChanges) {
reloadLibrary(page);
}
});
});
}
function deleteVirtualFolder(page, virtualFolder) {
var msg = globalize.translate("MessageAreYouSureYouWishToRemoveMediaFolder");
if (virtualFolder.Locations.length) {
msg += "<br/><br/>" + globalize.translate("MessageTheFollowingLocationWillBeRemovedFromLibrary") + "<br/><br/>";
msg += virtualFolder.Locations.join("<br/>");
}
require(["confirm"], function(confirm) {
confirm(msg, globalize.translate("HeaderRemoveMediaFolder")).then(function() {
require(["confirm"], function (confirm) {
confirm({
text: msg,
title: globalize.translate('HeaderRemoveMediaFolder'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
var refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function() {
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () {
reloadLibrary(page);
})
})
})
});
});
});
}
function refreshVirtualFolder(page, virtualFolder) {
require(["refreshDialog"], function(refreshDialog) {
require(["refreshDialog"], function (refreshDialog) {
new refreshDialog({
itemIds: [virtualFolder.ItemId],
serverId: ApiClient.serverId(),
@ -52,14 +65,14 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
}
function renameVirtualFolder(page, virtualFolder) {
require(["prompt"], function(prompt) {
require(["prompt"], function (prompt) {
prompt({
label: globalize.translate("LabelNewName"),
confirmText: globalize.translate("ButtonRename")
}).then(function(newName) {
}).then(function (newName) {
if (newName && newName != virtualFolder.Name) {
var refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).then(function() {
ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).then(function () {
reloadLibrary(page);
});
}
@ -97,24 +110,29 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
id: "refresh",
ironIcon: "refresh"
});
require(["actionsheet"], function(actionsheet) {
require(["actionsheet"], function (actionsheet) {
actionsheet.show({
items: menuItems,
positionTo: elem,
callback: function(resultId) {
callback: function (resultId) {
switch (resultId) {
case "edit":
editVirtualFolder(page, virtualFolder);
break;
case "editimages":
editImages(page, virtualFolder);
break;
case "rename":
renameVirtualFolder(page, virtualFolder);
break;
case "delete":
deleteVirtualFolder(page, virtualFolder);
break;
case "refresh":
refreshVirtualFolder(page, virtualFolder);
}
@ -125,7 +143,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
function reloadLibrary(page) {
loading.show();
ApiClient.getVirtualFolders().then(function(result) {
ApiClient.getVirtualFolders().then(function (result) {
reloadVirtualFolders(page, result);
});
}
@ -148,36 +166,40 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
for (var i = 0; i < virtualFolders.length; i++) {
var virtualFolder = virtualFolders[i];
html += getVirtualFolderHtml(page, virtualFolder, i)
html += getVirtualFolderHtml(page, virtualFolder, i);
}
var divVirtualFolders = page.querySelector("#divVirtualFolders");
divVirtualFolders.innerHTML = html;
divVirtualFolders.classList.add("itemsContainer");
divVirtualFolders.classList.add("vertical-wrap");
$(".btnCardMenu", divVirtualFolders).on("click", function() {
$(".btnCardMenu", divVirtualFolders).on("click", function () {
showCardMenu(page, this, virtualFolders);
});
divVirtualFolders.querySelector(".addLibrary").addEventListener("click", function() {
divVirtualFolders.querySelector(".addLibrary").addEventListener("click", function () {
addVirtualFolder(page);
});
$(".editLibrary", divVirtualFolders).on("click", function() {
$(".editLibrary", divVirtualFolders).on("click", function () {
var card = $(this).parents(".card")[0];
var index = parseInt(card.getAttribute("data-index"));
var virtualFolder = virtualFolders[index];
virtualFolder.ItemId && editVirtualFolder(page, virtualFolder);
if (virtualFolder.ItemId) {
editVirtualFolder(page, virtualFolder);
}
});
loading.hide();
}
function editImages(page, virtualFolder) {
require(["imageEditor"], function(imageEditor) {
require(["imageEditor"], function (imageEditor) {
imageEditor.show({
itemId: virtualFolder.ItemId,
serverId: ApiClient.serverId()
}).then(function() {
}).then(function () {
reloadLibrary(page);
});
})
});
}
function getLink(text, url) {
@ -214,25 +236,32 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
name: globalize.translate("FolderTypeUnset"),
value: "mixed",
message: globalize.translate("MessageUnsetContentHelp")
}]
}];
}
function getVirtualFolderHtml(page, virtualFolder, index) {
var html = "";
var style = "";
page.classList.contains("wizardPage") && (style += "min-width:33.3%;");
if (page.classList.contains("wizardPage")) {
style += "min-width:33.3%;";
}
html += '<div class="card backdropCard scalableCard backdropCard-scalable" style="' + style + '" data-index="' + index + '" data-id="' + virtualFolder.ItemId + '">';
html += '<div class="cardBox visualCardBox">';
html += '<div class="cardScalable visualCardBox-cardScalable">';
html += '<div class="cardPadder cardPadder-backdrop"></div>';
html += '<div class="cardContent">';
var imgUrl = "";
if (virtualFolder.PrimaryImageItemId) {
imgUrl = ApiClient.getScaledImageUrl(virtualFolder.PrimaryImageItemId, {
type: "Primary"
});
}
var hasCardImageContainer;
if (imgUrl) {
html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;background-image:url(\'' + imgUrl + "');\">";
hasCardImageContainer = true;
@ -241,38 +270,60 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || imageHelper.getLibraryIcon(virtualFolder.CollectionType)) + "</i>";
hasCardImageContainer = true;
}
if (hasCardImageContainer) {
html += '<div class="cardIndicators backdropCardIndicators">';
html += '<div is="emby-itemrefreshindicator"' + (virtualFolder.RefreshProgress || virtualFolder.RefreshStatus && "Idle" !== virtualFolder.RefreshStatus ? "" : ' class="hide"') + ' data-progress="' + (virtualFolder.RefreshProgress || 0) + '" data-status="' + virtualFolder.RefreshStatus + '"></div>';
html += "</div>";
html += "</div>";
}
if (!imgUrl && virtualFolder.showNameWithIcon) {
html += '<h3 class="cardImageContainer addLibrary" style="position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;flex-direction:column;">';
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || imageHelper.getLibraryIcon(virtualFolder.CollectionType)) + "</i>";
virtualFolder.showNameWithIcon && (html += '<div style="margin:1em 0;position:width:100%;">', html += virtualFolder.Name, html += "</div>");
if (virtualFolder.showNameWithIcon) {
html += '<div style="margin:1em 0;position:width:100%;">';
html += virtualFolder.Name;
html += "</div>";
}
html += "</h3>";
}
html += "</div>";
html += "</div>";
html += '<div class="cardFooter visualCardBox-cardFooter">';
// always show menu unless explicitly hidden
html += "</div>";
html += "</div>";
html += '<div class="cardFooter visualCardBox-cardFooter">'; // always show menu unless explicitly hidden
if (virtualFolder.showMenu !== false) {
html += '<div style="text-align:right; float:right;padding-top:5px;">';
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><i class="md-icon">&#xE5D3;</i></button>';
html += "</div>";
}
html += "<div class='cardText'>";
virtualFolder.showNameWithIcon ? html += "&nbsp;" : html += virtualFolder.Name;
if (virtualFolder.showNameWithIcon) {
html += "&nbsp;";
} else {
html += virtualFolder.Name;
}
html += "</div>";
var typeName = getCollectionTypeOptions().filter(function(t) {
return t.value == virtualFolder.CollectionType
var typeName = getCollectionTypeOptions().filter(function (t) {
return t.value == virtualFolder.CollectionType;
})[0];
typeName = typeName ? typeName.name : globalize.translate("FolderTypeUnset");
html += "<div class='cardText cardText-secondary'>";
virtualFolder.showType === false ? html += "&nbsp;" : html += typeName;
if (virtualFolder.showType === false) {
html += "&nbsp;";
} else {
html += typeName;
}
html += "</div>";
if (virtualFolder.showLocations === false) {
html += "<div class='cardText cardText-secondary'>";
html += "&nbsp;";
@ -286,6 +337,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
html += globalize.translate("NumLocationsValue", virtualFolder.Locations.length);
html += "</div>";
}
html += "</div>";
html += "</div>";
html += "</div>";
@ -305,18 +357,18 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
}, {
href: "metadatanfo.html",
name: globalize.translate("TabNfoSettings")
}]
}];
}
window.WizardLibraryPage = {
next: function() {
Dashboard.navigate("wizardsettings.html")
next: function () {
Dashboard.navigate("wizardsettings.html");
}
};
pageClassOn("pageshow", "mediaLibraryPage", function() {
pageClassOn("pageshow", "mediaLibraryPage", function () {
reloadLibrary(this);
});
pageIdOn("pageshow", "mediaLibraryPage", function() {
pageIdOn("pageshow", "mediaLibraryPage", function () {
libraryMenu.setTabs("librarysetup", 0, getTabs);
var page = this;
taskButton({
@ -326,7 +378,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
button: page.querySelector(".btnRefresh")
});
});
pageIdOn("pagebeforehide", "mediaLibraryPage", function() {
pageIdOn("pagebeforehide", "mediaLibraryPage", function () {
var page = this;
taskButton({
mode: "off",

View File

@ -9,7 +9,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
title: globalize.translate("DeleteUser"),
text: msg,
confirmText: globalize.translate("ButtonDelete"),
primary: "cancel"
primary: "delete"
}).then(function () {
loading.show();
ApiClient.deleteUser(id).then(function () {