Skip to content
Permalink
Browse files

Merge pull request #336 from lusbenjamin/history-unarchive

Archived Filter and History Unarchive
  • Loading branch information...
Manuel-777 committed May 14, 2019
2 parents e8ace88 + 0a93317 commit a1b69130c7aa875b753a589d7bafac0b536a0254
BIN +3.56 KB images/hide.png
Binary file not shown.
BIN +3.27 KB images/show.png
Binary file not shown.
@@ -76,7 +76,8 @@ class Aggregator {
onlyCurrentDecks: false,
arch: DEFAULT_ARCH,
oppColors: Aggregator.getDefaultColorFilter(),
date: DATE_LAST_30
date: DATE_LAST_30,
showArchived: false
};
}

@@ -151,8 +152,9 @@ class Aggregator {
}

filterDeck(deck) {
const { tag, colors, deckId, onlyCurrentDecks } = this.filters;
const { tag, colors, deckId, onlyCurrentDecks, showArchived } = this.filters;
if (!deck) return deckId === DEFAULT_DECK;
if (!showArchived && deck.archived && deck.archived) return false;
const passesDeckFilter = deckId === DEFAULT_DECK || deckId === deck.id;
if (!passesDeckFilter) return false;

@@ -194,8 +196,8 @@ class Aggregator {

filterMatch(match) {
if (!match) return false;
if (match.archived && match.archived == true) return false;
const { eventId, oppColors, arch, date } = this.filters;
const { eventId, oppColors, arch, date, showArchived } = this.filters;
if (!showArchived && match.archived && match.archived) return false;

const passesEventFilter =
this.filterEvent(match.eventId) ||
@@ -436,6 +436,14 @@ ipc.on("archive_match", function(event, arg) {
ipc_send("hide_loading");
});

//
ipc.on("unarchive_match", function(event, arg) {
ipc_send("show_loading");
history[arg].archived = false;
store.set(arg, history[arg]);
ipc_send("hide_loading");
});

//
ipc.on("archive_economy", function(event, _id) {
ipc_send("show_loading");
@@ -33,7 +33,8 @@ class FilterPanel {
showManaFilter,
archs,
showOppManaFilter,
archCounts
archCounts,
showArchivedFilter
) {
this.prefixId = prefixId;
this.onFilterChange = onFilterChange;
@@ -48,6 +49,7 @@ class FilterPanel {
this.archs = archs || [];
this.showOppManaFilter = showOppManaFilter || false;
this.archCounts = archCounts;
this.showArchivedFilter = showArchivedFilter || false;
this.getTagString = this.getTagString.bind(this);
this.getDeckString = this.getDeckString.bind(this);
return this;
@@ -97,6 +99,8 @@ class FilterPanel {
});
}
deckName += `<div class="flex_item">${colorsString}</div>`;
} else if (deck.archived) {
deckName += "<small><i> (archived)</i></small>";
} else {
deckName += "<small><i> (deleted)</i></small>";
}
@@ -112,8 +116,12 @@ class FilterPanel {
container.style.justifyContent = "space-between";

const columnA = createDivision([]);

const dataCont = createDivision([]);

dataCont.style.display = "flex";
const dateSelect = createSelect(
columnA,
dataCont,
[DATE_ALL_TIME, DATE_SEASON, DATE_LAST_30],
this.filters.date,
filter => {
@@ -123,6 +131,30 @@ class FilterPanel {
this.prefixId + "_query_date"
);
dateSelect.style.marginBottom = "8px";

if (this.showArchivedFilter) {
const archiveCont = document.createElement("label");
archiveCont.style.marginTop = "4px";
archiveCont.classList.add("check_container", "hover_label");
archiveCont.innerHTML = "archived";
const archiveCheckbox = document.createElement("input");
archiveCheckbox.type = "checkbox";
archiveCheckbox.id = this.prefixId + "_query_archived";
archiveCheckbox.addEventListener("click", () => {
const showArchived = archiveCheckbox.checked;
this.filters.showArchived = showArchived;
this.onFilterChange({ showArchived }, this.filters);
});
archiveCheckbox.checked = this.filters.showArchived;
archiveCont.appendChild(archiveCheckbox);
const archiveSpan = document.createElement("span");
archiveSpan.classList.add("checkmark");
archiveCont.appendChild(archiveSpan);
dataCont.appendChild(archiveCont);
}

columnA.appendChild(dataCont);

if (this.events.length) {
const eventSelect = createSelect(
columnA,
@@ -143,7 +143,8 @@ function openHistoryTab(_deprecated, _filters = {}) {
true,
matchesInEvent.archs,
true,
matchesInEvent.archCounts
matchesInEvent.archCounts,
true
);
const historyTopFilter = filterPanel.render();
historyTop.appendChild(historyTopFilter);
@@ -199,12 +200,16 @@ function renderData(container, index) {
clickCallback = openDraft;
deleteCallback = archiveMatch;
}
if (match.archived) {
deleteCallback = unarchiveMatch;
}

let listItem = new ListItem(
tileGrpid,
match.id,
clickCallback,
deleteCallback
deleteCallback,
match.archived
);
listItem.divideLeft();
listItem.divideRight();
@@ -227,6 +232,14 @@ function renderData(container, index) {

function archiveMatch(id) {
ipc_send("archive_match", id);
matchesHistory[id].archived = true;
openHistoryTab();
}

function unarchiveMatch(id) {
ipc_send("unarchive_match", id);
matchesHistory[id].archived = false;
openHistoryTab();
}

function openMatch(id) {
@@ -3199,10 +3199,18 @@ a:hover {
width: 200px;
}

.list_item_delete {
.list_item_archive {
width: 4px;
margin-left: 8px;
overflow: hidden;
background: #DD8263 url(../images/delete.png) no-repeat left;
background: #DD8263 url(../images/hide.png) no-repeat left;
-webkit-transition: all .25s cubic-bezier(0.2, 0.5, 0.35, 1);
}

.list_item_unarchive {
width: 4px;
margin-left: 8px;
overflow: hidden;
background: #B7C89E url(../images/show.png) no-repeat left;
-webkit-transition: all .25s cubic-bezier(0.2, 0.5, 0.35, 1);
}
@@ -7,7 +7,7 @@ globals
*/

class ListItem {
constructor(_grpId, _id, _onClick, _onDelete = false) {
constructor(_grpId, _id, _onClick, _onDelete = false, isArchived = false) {
this.onClickCallback = _onClick;
if (typeof _onDelete == "function") {
this.onDeleteCallback = _onDelete;
@@ -19,10 +19,13 @@ class ListItem {
this.left = createDivision(["list_item_left"]);
this.center = createDivision(["list_item_center"]);
this.right = createDivision(["list_item_right"]);
this.deleteButton = createDivision(["list_item_delete"]);
this.deleteButton.title = `will archive this and hide from most areas of the tool
(no undo yet, but will not delete data)`;

const archiveClass = isArchived
? "list_item_unarchive"
: "list_item_archive";
this.deleteButton = createDivision([archiveClass]);
this.deleteButton.title = isArchived
? "restore"
: "archive (will not delete data)";
let cardObj = cardsDb.get(_grpId);
this.imageContainer = createDivision(["list_item_image"]);
try {

0 comments on commit a1b6913

Please sign in to comment.
You can’t perform that action at this time.