mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
Utilize pluralize filter
This commit is contained in:
parent
10d2492232
commit
226c5e5bdb
6 changed files with 12 additions and 12 deletions
|
@ -97,7 +97,7 @@ export default {
|
||||||
e.dataTransfer.effectAllowed = 'move'
|
e.dataTransfer.effectAllowed = 'move'
|
||||||
|
|
||||||
// Set a fancy drop image using our ghost element.
|
// Set a fancy drop image using our ghost element.
|
||||||
const $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} in ${this.album.name}`)
|
const $ghost = $('#dragGhost').text(`All ${pluralize(songIds.length, 'song')} in ${this.album.name}`)
|
||||||
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ export default {
|
||||||
e.dataTransfer.effectAllowed = 'move'
|
e.dataTransfer.effectAllowed = 'move'
|
||||||
|
|
||||||
// Set a fancy drop image using our ghost element.
|
// Set a fancy drop image using our ghost element.
|
||||||
const $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} by ${this.artist.name}`)
|
const $ghost = $('#dragGhost').text(`All ${pluralize(songIds.length, 'song')} by ${this.artist.name}`)
|
||||||
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ import { find, invokeMap, filter, map } from 'lodash'
|
||||||
import isMobile from 'ismobilejs'
|
import isMobile from 'ismobilejs'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
|
||||||
import { filterBy, orderBy, limitBy, event } from '../../utils'
|
import { filterBy, orderBy, limitBy, event, pluralize } from '../../utils'
|
||||||
import { playlistStore, queueStore, songStore, favoriteStore } from '../../stores'
|
import { playlistStore, queueStore, songStore, favoriteStore } from '../../stores'
|
||||||
import { playback } from '../../services'
|
import { playback } from '../../services'
|
||||||
import router from '../../router'
|
import router from '../../router'
|
||||||
|
@ -347,7 +347,7 @@ export default {
|
||||||
e.dataTransfer.effectAllowed = 'move'
|
e.dataTransfer.effectAllowed = 'move'
|
||||||
|
|
||||||
// Set a fancy drop image using our ghost element.
|
// Set a fancy drop image using our ghost element.
|
||||||
const $ghost = $('#dragGhost').text(`${songIds.length} song${songIds.length === 1 ? '' : 's'}`)
|
const $ghost = $('#dragGhost').text(`${pluralize(songIds.length, 'song')}`)
|
||||||
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
e.dataTransfer.setDragImage($ghost[0], 0, 0)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { each, map, difference, union } from 'lodash'
|
||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
|
|
||||||
import { http } from '../services'
|
import { http } from '../services'
|
||||||
import { alerts } from '../utils'
|
import { alerts, pluralize } from '../utils'
|
||||||
|
|
||||||
export const favoriteStore = {
|
export const favoriteStore = {
|
||||||
state: {
|
state: {
|
||||||
|
@ -93,7 +93,7 @@ export const favoriteStore = {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post('interaction/batch/like', { songs: map(songs, 'id') }, data => {
|
http.post('interaction/batch/like', { songs: map(songs, 'id') }, data => {
|
||||||
alerts.success(`Added ${songs.length} song${songs.length === 1 ? '' : 's'} into Favorites.`)
|
alerts.success(`Added ${pluralize(songs.length, 'song')} into Favorites.`)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}, r => reject(r))
|
}, r => reject(r))
|
||||||
})
|
})
|
||||||
|
@ -114,7 +114,7 @@ export const favoriteStore = {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post('interaction/batch/unlike', { songs: map(songs, 'id') }, data => {
|
http.post('interaction/batch/unlike', { songs: map(songs, 'id') }, data => {
|
||||||
alerts.success(`Removed ${songs.length} song${songs.length === 1 ? '' : 's'} from Favorites.`)
|
alerts.success(`Removed ${pluralize(songs.length, 'song')} from Favorites.`)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}, r => reject(r))
|
}, r => reject(r))
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,7 +3,7 @@ import NProgress from 'nprogress'
|
||||||
|
|
||||||
import stub from '../stubs/playlist'
|
import stub from '../stubs/playlist'
|
||||||
import { http } from '../services'
|
import { http } from '../services'
|
||||||
import { alerts } from '../utils'
|
import { alerts, pluralize } from '../utils'
|
||||||
import { songStore } from '.'
|
import { songStore } from '.'
|
||||||
|
|
||||||
export const playlistStore = {
|
export const playlistStore = {
|
||||||
|
@ -148,7 +148,7 @@ export const playlistStore = {
|
||||||
|
|
||||||
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
|
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
|
||||||
data => {
|
data => {
|
||||||
alerts.success(`Added ${songs.length} song${songs.length === 1 ? '' : 's'} into "${playlist.name}".`)
|
alerts.success(`Added ${pluralize(songs.length, 'song')} into "${playlist.name}".`)
|
||||||
resolve(playlist)
|
resolve(playlist)
|
||||||
},
|
},
|
||||||
r => reject(r)
|
r => reject(r)
|
||||||
|
@ -170,7 +170,7 @@ export const playlistStore = {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
|
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
|
||||||
data => {
|
data => {
|
||||||
alerts.success(`Removed ${songs.length} song${songs.length === 1 ? '' : 's'} from "${playlist.name}".`)
|
alerts.success(`Removed ${pluralize(songs.length, 'song')} from "${playlist.name}".`)
|
||||||
resolve(playlist)
|
resolve(playlist)
|
||||||
},
|
},
|
||||||
r => reject(r)
|
r => reject(r)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Vue from 'vue'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
import { without, map, take, remove, orderBy, each, union } from 'lodash'
|
import { without, map, take, remove, orderBy, each, union } from 'lodash'
|
||||||
|
|
||||||
import { secondsToHis, alerts } from '../utils'
|
import { secondsToHis, alerts, pluralize } from '../utils'
|
||||||
import { http, ls } from '../services'
|
import { http, ls } from '../services'
|
||||||
import { sharedStore, favoriteStore, albumStore, artistStore } from '.'
|
import { sharedStore, favoriteStore, albumStore, artistStore } from '.'
|
||||||
import stub from '../stubs/song'
|
import stub from '../stubs/song'
|
||||||
|
@ -226,7 +226,7 @@ export const songStore = {
|
||||||
songs: map(songs, 'id')
|
songs: map(songs, 'id')
|
||||||
}, songs => {
|
}, songs => {
|
||||||
each(songs, song => this.syncUpdatedSong(song))
|
each(songs, song => this.syncUpdatedSong(song))
|
||||||
alerts.success(`Updated ${songs.length} song${songs.length === 1 ? '' : 's'}.`)
|
alerts.success(`Updated ${pluralize(songs.length, 'song')}.`)
|
||||||
resolve(songs)
|
resolve(songs)
|
||||||
}, r => reject(r))
|
}, r => reject(r))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue