Bug fixes

This commit is contained in:
sairaj mote 2022-07-14 16:16:20 +05:30
parent 450d4c9e5c
commit 1e8d7f18a5

View File

@ -201,7 +201,17 @@
</svg> </svg>
Edit title & sections Edit title & sections
</menu-option> </menu-option>
<menu-option onclick="setDefaultArticle()"> <menu-option id="mark_as_wip" class="hidden" onclick="markAsWIP()">
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg"
enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px"
fill="#000000">
<rect fill="none" height="24" width="24" />
<path
d="M22,12c0,5.52-4.48,10-10,10S2,17.52,2,12c0-2.76,1.12-5.26,2.93-7.07L12,12V2C17.52,2,22,6.48,22,12z" />
</svg>
Mark as WIP
</menu-option>
<menu-option id="mark_as_done" class="hidden" onclick="markAsDone()">
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" <svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg"
enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px"
fill="#000000"> fill="#000000">
@ -213,7 +223,7 @@
d="M14,2H6C4.9,2,4.01,2.9,4.01,4L4,20c0,1.1,0.89,2,1.99,2H18c1.1,0,2-0.9,2-2V8L14,2z M18,20H6V4h7v5h5V20z M8.82,13.05 L7.4,14.46L10.94,18l5.66-5.66l-1.41-1.41l-4.24,4.24L8.82,13.05z" /> d="M14,2H6C4.9,2,4.01,2.9,4.01,4L4,20c0,1.1,0.89,2,1.99,2H18c1.1,0,2-0.9,2-2V8L14,2z M18,20H6V4h7v5h5V20z M8.82,13.05 L7.4,14.46L10.94,18l5.66-5.66l-1.41-1.41l-4.24,4.24L8.82,13.05z" />
</g> </g>
</svg> </svg>
Make default article Mark as Done
</menu-option> </menu-option>
</sm-menu> </sm-menu>
</div> </div>
@ -422,14 +432,14 @@
</header> </header>
<sm-form> <sm-form>
<sm-input id="get_article_title" placeholder="Article title" required autofocus></sm-input> <sm-input id="get_article_title" placeholder="Article title" required autofocus></sm-input>
<sm-checkbox id="set_default_checkbox" checked> <!-- <sm-checkbox id="set_default_checkbox" checked>
<div class="grid margin-left-0-5 gap-0-5"> <div class="grid margin-left-0-5 gap-0-5">
Set as default Set as default
<p style="font-size: 0.8rem;"> <p style="font-size: 0.8rem;">
This article will be opened by default for everyone when CC is first loaded. This article will be opened by default for everyone when CC is first loaded.
</p> </p>
</div> </div>
</sm-checkbox> </sm-checkbox> -->
<div class="grid gap-1"> <div class="grid gap-1">
<div class="grid gap-0-5"> <div class="grid gap-0-5">
<h4>Define plot (optional)</h4> <h4>Define plot (optional)</h4>
@ -592,8 +602,8 @@
BTC integrated with FLO BTC integrated with FLO
</h4> </h4>
<p> <p>
You can use your FLO private key to perform transaction on BTC network within our apps ecosystem. You can use your FLO private key to perform transactions on the BTC network within our app
The private key is same for both. ecosystem. The private key is the same for both.
</p> </p>
</div> </div>
<div class="grid gap-0-5"> <div class="grid gap-0-5">
@ -997,6 +1007,14 @@
const urlSearchParams = new URLSearchParams('?' + searchParams); const urlSearchParams = new URLSearchParams('?' + searchParams);
params = Object.fromEntries(urlSearchParams.entries()); 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) { switch (pageId) {
case 'landing': case 'landing':
targetPage = 'landing' targetPage = 'landing'
@ -1015,18 +1033,17 @@
break; break;
case 'home': case 'home':
case 'main_page': 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) { if (!floGlobals.currentArticle.id || params.articleID !== pagesData.params.articleID || params.focusMode !== pagesData.params.focusMode) {
closePopup() closePopup()
render.article(params.articleID, params.focusMode === 'true') 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() hideVersionHistory()
window.history.replaceState('', '', `#/home?articleID=${params.articleID}&focusMode=${params.hasOwnProperty('focusMode') ? params.focusMode : 'true'}`) window.history.replaceState('', '', `#/home?articleID=${params.articleID}&focusMode=${params.hasOwnProperty('focusMode') ? params.focusMode : 'true'}`)
renderElem(getRef('preview__body'), html``) renderElem(getRef('preview__body'), html``)
@ -1248,7 +1265,7 @@
createNewArticle() { createNewArticle() {
if (floGlobals.isSubAdmin) { if (floGlobals.isSubAdmin) {
const title = getRef('get_article_title').value.trim() 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 plot = getRef('get_plot').value.trim()
const sectionTitles = parsePlot(plot) const sectionTitles = parsePlot(plot)
let sections = [] let sections = []
@ -1261,8 +1278,8 @@
}) })
} }
const uid = floCrypto.randString(16, true) const uid = floCrypto.randString(16, true)
if (setDefault) if (!floGlobals.appObjects.cc['wipArticles'].includes(uid))
floGlobals.appObjects.cc['defaultArticle'] = uid floGlobals.appObjects.cc['wipArticles'].push(uid)
floGlobals.appObjects.cc['articleList'][uid] = { floGlobals.appObjects.cc['articleList'][uid] = {
title, title,
timestamp: Date.now(), timestamp: Date.now(),
@ -1320,16 +1337,54 @@
return tstring; return tstring;
} }
function setDefaultArticle() { function markAsWIP() {
if (floGlobals.isSubAdmin) { if (floGlobals.isSubAdmin) {
getConfirmation('Set as default article?').then(res => { getConfirmation('Mark as WIP article?').then(res => {
if (res) { if (res) {
floGlobals.appObjects.cc['defaultArticle'] = floGlobals.currentArticle.id if (!floGlobals.appObjects.cc['wipArticles'].includes(floGlobals.currentArticle.id)) {
floCloudAPI.updateObjectData('cc') floGlobals.appObjects.cc['wipArticles'].push(floGlobals.currentArticle.id)
.then((res) => { floCloudAPI.updateObjectData('cc')
notify('Set current article as default', 'success') .then((res) => {
}) notify('Marked current article as WIP', 'success')
.catch(err => console.error(err)) 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 { } else {
@ -1680,7 +1735,7 @@
} }
getRef('current_article_title').textContent = title getRef('current_article_title').textContent = title
getRef('article_wrapper').innerHTML = '' 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(render.section(assignedSection, sections[assignedSection]))
getRef('article_wrapper').append(html.node` getRef('article_wrapper').append(html.node`
<div id="focus_mode_panel" class="flex align-center space-between"> <div id="focus_mode_panel" class="flex align-center space-between">
@ -2416,9 +2471,8 @@
getRef('sort_article_list').addEventListener('change', e => { renderArticleList() }) getRef('sort_article_list').addEventListener('change', e => { renderArticleList() })
function renderArticleList(articleList) { function renderArticleList(articleList) {
const defaultArticle = floGlobals.appObjects.cc.defaultArticle;
const articlesList = (articleList || getArticleList()).map((article) => { 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')) return render.articleLink(article, isDefaultArticle, getRef('article_list'))
}) })
renderElem(getRef('article_list'), html`${articlesList}`) renderElem(getRef('article_list'), html`${articlesList}`)