Add bottom controls buttons for uploads list

This commit is contained in:
Bobby Wibowo 2020-05-02 22:09:51 +07:00
parent 19b4a5e217
commit 89e5f775ec
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
4 changed files with 28 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -382,7 +382,7 @@ page.domClick = event => {
case 'select-all': case 'select-all':
return page.selectAll(element) return page.selectAll(element)
case 'page-ellipsis': case 'page-ellipsis':
return page.focusJumpToPage() return page.focusJumpToPage(element)
case 'page-prev': case 'page-prev':
case 'page-next': case 'page-next':
case 'page-goto': case 'page-goto':
@ -436,7 +436,7 @@ page.switchPage = (action, element) => {
params.pageNum = parseInt(element.dataset.goto) params.pageNum = parseInt(element.dataset.goto)
return func(params) return func(params)
case 'jump-to-page': { case 'jump-to-page': {
const jumpToPage = document.querySelector('#jumpToPage') const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)
if (!jumpToPage.checkValidity()) return if (!jumpToPage.checkValidity()) return
const parsed = parseInt(jumpToPage.value) const parsed = parseInt(jumpToPage.value)
params.pageNum = isNaN(parsed) ? 0 : (parsed - 1) params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)
@ -446,11 +446,11 @@ page.switchPage = (action, element) => {
} }
} }
page.focusJumpToPage = () => { page.focusJumpToPage = element => {
const element = document.querySelector('#jumpToPage') const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)
if (!element) return if (!jumpToPage) return
element.focus() jumpToPage.focus()
element.select() jumpToPage.select()
} }
page.getUploads = (params = {}) => { page.getUploads = (params = {}) => {
@ -593,6 +593,17 @@ page.getUploads = (params = {}) => {
</div> </div>
` `
// Do some string replacements for bottom controls
const bottomFiltersId = 'bFilters'
const bottomJumpId = 'bJumpToPage'
const bottomExtraControls = extraControls
.replace(/id="filters"/, `id="${bottomFiltersId}"`)
.replace(/(data-action="filter-uploads")/, `$1 data-filtersid="${bottomFiltersId}"`)
.replace(/id="jumpToPage"/, `id="${bottomJumpId}"`)
.replace(/(data-action="jump-to-page")/g, `$1 data-jumpid="${bottomJumpId}"`)
const bottomPagination = pagination
.replace(/(data-action="page-ellipsis")/g, `$1 data-jumpid="${bottomJumpId}"`)
// Whether there are any unselected items // Whether there are any unselected items
let unselected = false let unselected = false
@ -654,7 +665,9 @@ page.getUploads = (params = {}) => {
${controls} ${controls}
<div id="table" class="columns is-multiline is-mobile is-centered"> <div id="table" class="columns is-multiline is-mobile is-centered">
</div> </div>
${pagination} ${controls}
${bottomExtraControls}
${bottomPagination}
` `
const table = document.querySelector('#table') const table = document.querySelector('#table')
@ -729,7 +742,9 @@ page.getUploads = (params = {}) => {
</tbody> </tbody>
</table> </table>
</div> </div>
${pagination} ${controls}
${bottomExtraControls}
${bottomPagination}
` `
const table = document.querySelector('#table') const table = document.querySelector('#table')
@ -1067,7 +1082,7 @@ page.uploadFiltersHelp = element => {
} }
page.filterUploads = element => { page.filterUploads = element => {
const filters = document.querySelector('#filters').value.trim() const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value.trim()
page.getUploads({ all: true, filters }, element) page.getUploads({ all: true, filters }, element)
} }

View File

@ -1,5 +1,5 @@
{ {
"1": "1588200827", "1": "1588432149",
"2": "1581416390", "2": "1581416390",
"3": "1581416390", "3": "1581416390",
"4": "1581416390", "4": "1581416390",