Utilize pluralize filter

This commit is contained in:
An Phan 2016-12-19 13:37:30 +08:00
parent 10d2492232
commit 226c5e5bdb
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2
6 changed files with 12 additions and 12 deletions

View file

@ -97,7 +97,7 @@ export default {
e.dataTransfer.effectAllowed = 'move'
// 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)
}
}

View file

@ -86,7 +86,7 @@ export default {
e.dataTransfer.effectAllowed = 'move'
// 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)
}
}

View file

@ -54,7 +54,7 @@ import { find, invokeMap, filter, map } from 'lodash'
import isMobile from 'ismobilejs'
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 { playback } from '../../services'
import router from '../../router'
@ -347,7 +347,7 @@ export default {
e.dataTransfer.effectAllowed = 'move'
// 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)
})
},

View file

@ -2,7 +2,7 @@ import { each, map, difference, union } from 'lodash'
import NProgress from 'nprogress'
import { http } from '../services'
import { alerts } from '../utils'
import { alerts, pluralize } from '../utils'
export const favoriteStore = {
state: {
@ -93,7 +93,7 @@ export const favoriteStore = {
return new Promise((resolve, reject) => {
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)
}, r => reject(r))
})
@ -114,7 +114,7 @@ export const favoriteStore = {
return new Promise((resolve, reject) => {
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)
}, r => reject(r))
})

View file

@ -3,7 +3,7 @@ import NProgress from 'nprogress'
import stub from '../stubs/playlist'
import { http } from '../services'
import { alerts } from '../utils'
import { alerts, pluralize } from '../utils'
import { songStore } from '.'
export const playlistStore = {
@ -148,7 +148,7 @@ export const playlistStore = {
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
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)
},
r => reject(r)
@ -170,7 +170,7 @@ export const playlistStore = {
return new Promise((resolve, reject) => {
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') },
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)
},
r => reject(r)

View file

@ -2,7 +2,7 @@ import Vue from 'vue'
import slugify from 'slugify'
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 { sharedStore, favoriteStore, albumStore, artistStore } from '.'
import stub from '../stubs/song'
@ -226,7 +226,7 @@ export const songStore = {
songs: map(songs, 'id')
}, songs => {
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)
}, r => reject(r))
})