Skip to content

Commit

Permalink
fix: some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Jan 10, 2024
1 parent 9c45c27 commit 0e0c9af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
30 changes: 17 additions & 13 deletions EMS/admin-ui-bundle/assets/js/core/components/mediaLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class MediaLibrary {
#options = {}
#elements = {}
#loadedFiles = 0
#fileUploaders = []

constructor (el, options) {
this.#options = options
Expand Down Expand Up @@ -42,13 +43,17 @@ export default class MediaLibrary {
}

_disableButtons () {
this.#el.querySelectorAll('button').forEach(button => button.disabled = true)
this.#el.querySelectorAll('button').forEach(button => {
button.disabled = true
})
const uploadLabel = this.uploadLabel()
if (uploadLabel) uploadLabel.setAttribute('disabled', 'disabled')
}

_enableButtons () {
this.#el.querySelectorAll('button').forEach(button => button.disabled = false)
this.#el.querySelectorAll('button').forEach(button => {
button.disabled = false
})
const uploadLabel = this.uploadLabel()
if (uploadLabel) uploadLabel.removeAttribute('disabled')
}
Expand Down Expand Up @@ -145,8 +150,7 @@ export default class MediaLibrary {
liUpload.append(progressBar.element())
this.#elements.listUploads.appendChild(liUpload)

console.log(this.#options)
new FileUploader({
this.#fileUploaders.push(new FileUploader({
file,
algo: this.#options.hashAlgo,
initUrl: this.#options.urlInitUpload,
Expand Down Expand Up @@ -186,7 +190,7 @@ export default class MediaLibrary {
mediaLib.#elements.listUploads.removeChild(liUpload)
} else {
reject()
progressBar.status('Error: ' + message)
progressBar.status('Error: ' + request.statusText)
progressBar.progress(100)
progressBar.style('danger')
}
Expand All @@ -197,7 +201,7 @@ export default class MediaLibrary {
progressBar.progress(100)
progressBar.style('danger')
}
})
}))
})
}

Expand All @@ -206,7 +210,7 @@ export default class MediaLibrary {
url: [this.#url, 'add-folder'].join('/') + (this.#activeFolder ? '/' + this.#activeFolder : ''),
size: 'sm'
}, (json) => {
if (json.hasOwnProperty('success') && json.success === true) {
if (Object.prototype.hasOwnProperty.call(json, 'success') && json.success === true) {
this._disableButtons()
this._getFolders(json.path).then(() => this._enableButtons())
}
Expand Down Expand Up @@ -262,24 +266,24 @@ export default class MediaLibrary {
}

_appendFiles (json) {
if (json.hasOwnProperty('header')) {
if (Object.prototype.hasOwnProperty.call(json, 'header')) {
this.#elements.header.innerHTML = json.header
this._addEventListenersHeader()
}

if (json.hasOwnProperty('rowHeader')) {
if (Object.prototype.hasOwnProperty.call(json, 'rowHeader')) {
this.#elements.listFiles.innerHTML += json.rowHeader
}

if (json.hasOwnProperty('rows')) {
if (Object.prototype.hasOwnProperty.call(json, 'rows')) {
json.rows.forEach((row) => { this.#elements.listFiles.innerHTML += row })
}

if (json.hasOwnProperty('totalRows')) {
if (Object.prototype.hasOwnProperty.call(json, 'totalRows')) {
this.#loadedFiles += json.totalRows
}

if (json.hasOwnProperty('remaining') && json.remaining) {
if (Object.prototype.hasOwnProperty.call(json, 'remaining') && json.remaining) {
this.#elements.loadMoreFiles.classList.add('show-load-more')
} else {
this.#elements.loadMoreFiles.classList.remove('show-load-more')
Expand All @@ -298,7 +302,7 @@ export default class MediaLibrary {
const liFolder = document.createElement('li')
liFolder.appendChild(buttonFolder)

if (folder.hasOwnProperty('children')) {
if (Object.prototype.hasOwnProperty.call(folder, 'children')) {
const ulChildren = document.createElement('ul')
this._appendFolderItems(folder.children, ulChildren)
liFolder.appendChild(ulChildren)
Expand Down
17 changes: 8 additions & 9 deletions EMS/admin-ui-bundle/assets/js/core/helpers/ajaxModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,21 @@ class AjaxModal {

load (options, callback) {
const dialog = this.modal.querySelector('.modal-dialog')
console.log(dialog.classList)
dialog.classList.remove('modal-xs', 'modal-sm', 'modal-md', 'modal-lg')
if (options.hasOwnProperty('size')) {
if (Object.prototype.hasOwnProperty.call(options, 'size')) {
dialog.classList.add('modal-' + options.size)
} else {
dialog.classList.add('modal-md')
}

this.stateLoading()
if (options.hasOwnProperty('title')) {
if (Object.prototype.hasOwnProperty.call(options, 'title')) {
this.modal.querySelector('.modal-title').innerHTML = options.title
}
this.bsModal.show()

const fetchOptions = { method: 'GET', headers: { 'Content-Type': 'application/json' } }
if (options.hasOwnProperty('data')) {
if (Object.prototype.hasOwnProperty.call(options, 'data')) {
fetchOptions.method = 'POST'
fetchOptions.body = options.data
}
Expand Down Expand Up @@ -135,29 +134,29 @@ class AjaxModal {
}

ajaxReady (json, url, callback) {
if (json.hasOwnProperty('modalClose') && json.modalClose === true) {
if (Object.prototype.hasOwnProperty.call(json, 'modalClose') && json.modalClose === true) {
if (typeof callback === 'function') { callback(json, this.modal) }
this.bsModal.hide()
return
}

if (json.hasOwnProperty('modalTitle')) {
if (Object.prototype.hasOwnProperty.call(json, 'modalTitle')) {
this.$modal.find('.modal-title').html(json.modalTitle)
}
if (json.hasOwnProperty('modalBody')) {
if (Object.prototype.hasOwnProperty.call(json, 'modalBody')) {
this.$modal.find('.ajax-modal-body').html(json.modalBody)
this.$modal.find(':input').each(function () {
$(this).addClass('ignore-ems-update')
})
new AddedDomEvent(this.modal)
}
if (json.hasOwnProperty('modalFooter')) {
if (Object.prototype.hasOwnProperty.call(json, 'modalFooter')) {
this.$modal.find('.ajax-modal-footer').html(json.modalFooter)
} else {
this.$modal.find('.ajax-modal-footer').html('<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>')
}

const messages = json.hasOwnProperty('modalMessages') ? json.modalMessages : []
const messages = Object.prototype.hasOwnProperty.call(json, 'modalMessages') ? json.modalMessages : []
messages.forEach((m) => {
const messageType = Object.keys(m)[0]
const message = m[messageType]
Expand Down

0 comments on commit 0e0c9af

Please sign in to comment.