From 1e8d7f18a5ce3574f5be0de894c8829fb37b6e56 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Thu, 14 Jul 2022 16:16:20 +0530 Subject: [PATCH] Bug fixes --- index.html | 110 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index ac06f7e..5b2e750 100644 --- a/index.html +++ b/index.html @@ -201,7 +201,17 @@ Edit title & sections - + + @@ -422,14 +432,14 @@ - +

Define plot (optional)

@@ -592,8 +602,8 @@ BTC integrated with FLO

- You can use your FLO private key to perform transaction on BTC network within our apps ecosystem. - The private key is same for both. + You can use your FLO private key to perform transactions on the BTC network within our app + ecosystem. The private key is the same for both.

@@ -997,6 +1007,14 @@ const urlSearchParams = new URLSearchParams('?' + searchParams); params = Object.fromEntries(urlSearchParams.entries()); } + if (firstLoad || params.articleID !== pagesData.params.articleID) { + if (!params.articleID) + params['articleID'] = floGlobals.appObjects.cc.wipArticles[0] + await Promise.all([ + floCloudAPI.requestObjectData(params.articleID), + floCloudAPI.requestGeneralData(`${params.articleID}_gd`) + ]) + } switch (pageId) { case 'landing': targetPage = 'landing' @@ -1015,18 +1033,17 @@ break; case 'home': case 'main_page': - if (firstLoad || params.articleID !== pagesData.params.articleID) { - if (!params.articleID) - params['articleID'] = floGlobals.appObjects.cc.defaultArticle - await Promise.all([ - floCloudAPI.requestObjectData(params.articleID), - floCloudAPI.requestGeneralData(`${params.articleID}_gd`) - ]) - } if (!floGlobals.currentArticle.id || params.articleID !== pagesData.params.articleID || params.focusMode !== pagesData.params.focusMode) { closePopup() render.article(params.articleID, params.focusMode === 'true') } + if (floGlobals.appObjects.cc.wipArticles.includes(params.articleID)) { + getRef('mark_as_done').classList.remove('hidden') + getRef('mark_as_wip').classList.add('hidden') + } else { + getRef('mark_as_done').classList.add('hidden') + getRef('mark_as_wip').classList.remove('hidden') + } hideVersionHistory() window.history.replaceState('', '', `#/home?articleID=${params.articleID}&focusMode=${params.hasOwnProperty('focusMode') ? params.focusMode : 'true'}`) renderElem(getRef('preview__body'), html``) @@ -1248,7 +1265,7 @@ createNewArticle() { if (floGlobals.isSubAdmin) { const title = getRef('get_article_title').value.trim() - const setDefault = getRef('set_default_checkbox').checked + // const setDefault = getRef('set_default_checkbox').checked const plot = getRef('get_plot').value.trim() const sectionTitles = parsePlot(plot) let sections = [] @@ -1261,8 +1278,8 @@ }) } const uid = floCrypto.randString(16, true) - if (setDefault) - floGlobals.appObjects.cc['defaultArticle'] = uid + if (!floGlobals.appObjects.cc['wipArticles'].includes(uid)) + floGlobals.appObjects.cc['wipArticles'].push(uid) floGlobals.appObjects.cc['articleList'][uid] = { title, timestamp: Date.now(), @@ -1320,16 +1337,54 @@ return tstring; } - function setDefaultArticle() { + function markAsWIP() { if (floGlobals.isSubAdmin) { - getConfirmation('Set as default article?').then(res => { + getConfirmation('Mark as WIP article?').then(res => { if (res) { - floGlobals.appObjects.cc['defaultArticle'] = floGlobals.currentArticle.id - floCloudAPI.updateObjectData('cc') - .then((res) => { - notify('Set current article as default', 'success') - }) - .catch(err => console.error(err)) + if (!floGlobals.appObjects.cc['wipArticles'].includes(floGlobals.currentArticle.id)) { + floGlobals.appObjects.cc['wipArticles'].push(floGlobals.currentArticle.id) + floCloudAPI.updateObjectData('cc') + .then((res) => { + notify('Marked current article as WIP', 'success') + if (floGlobals.appObjects.cc.wipArticles.includes(floGlobals.currentArticle.id)) { + getRef('mark_as_done').classList.remove('hidden') + getRef('mark_as_wip').classList.add('hidden') + } else { + getRef('mark_as_done').classList.add('hidden') + getRef('mark_as_wip').classList.remove('hidden') + } + }) + .catch(err => console.error(err)) + } else { + notify('Current article is already default', 'error') + } + } + }) + } else { + notify('This action requires sub-admin privileges', 'error') + } + } + function markAsDone() { + if (floGlobals.isSubAdmin) { + getConfirmation('Mark as done article?').then(res => { + if (res) { + if (floGlobals.appObjects.cc['wipArticles'].includes(floGlobals.currentArticle.id)) { + floGlobals.appObjects.cc['wipArticles'] = floGlobals.appObjects.cc['wipArticles'].filter(id => id != floGlobals.currentArticle.id) + floCloudAPI.updateObjectData('cc') + .then((res) => { + notify('Marked current article as done', 'success') + if (floGlobals.appObjects.cc.wipArticles.includes(floGlobals.currentArticle.id)) { + getRef('mark_as_done').classList.remove('hidden') + getRef('mark_as_wip').classList.add('hidden') + } else { + getRef('mark_as_done').classList.add('hidden') + getRef('mark_as_wip').classList.remove('hidden') + } + }) + .catch(err => console.error(err)) + } else { + notify('Current article is already done', 'error') + } } }) } else { @@ -1680,7 +1735,7 @@ } getRef('current_article_title').textContent = title getRef('article_wrapper').innerHTML = '' - if (!floGlobals.isSubAdmin && focusMode && floGlobals.appObjects.cc.defaultArticle === id) { + if (!floGlobals.isSubAdmin && focusMode && floGlobals.appObjects.cc.wipArticles.includes(id)) { getRef('article_wrapper').append(render.section(assignedSection, sections[assignedSection])) getRef('article_wrapper').append(html.node`
@@ -2416,9 +2471,8 @@ getRef('sort_article_list').addEventListener('change', e => { renderArticleList() }) function renderArticleList(articleList) { - const defaultArticle = floGlobals.appObjects.cc.defaultArticle; const articlesList = (articleList || getArticleList()).map((article) => { - const isDefaultArticle = defaultArticle === article.uid + const isDefaultArticle = floGlobals.appObjects.cc.wipArticles.includes(article.uid) return render.articleLink(article, isDefaultArticle, getRef('article_list')) }) renderElem(getRef('article_list'), html`${articlesList}`)