fix authors sorting and add custom ordering on alphabetical list view
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
v-bind="{ node, mode, showOrigin }"
|
||||
class="node-view-header"
|
||||
:class="{ scrolling: scrollValue }"
|
||||
:first-char="firstChar"
|
||||
/>
|
||||
|
||||
<node-view-body v-bind="{ node, type: nodeType, mode }" :class="{ scrolling: scrollValue }"/>
|
||||
@@ -63,7 +64,8 @@ export default {
|
||||
forceType: { type: String, default: null },
|
||||
mode: { type: String, default: 'view' },
|
||||
preview: { type: Boolean, default: false },
|
||||
showOrigin: { type: Boolean, default: false }
|
||||
showOrigin: { type: Boolean, default: false },
|
||||
firstChar: { type: [String, null], default: null }
|
||||
},
|
||||
|
||||
data () {
|
||||
|
||||
@@ -33,7 +33,8 @@ export default {
|
||||
props: {
|
||||
node: { type: Object, required: true },
|
||||
mode: { type: String, required: true },
|
||||
showOrigin: { type: Boolean, required: true }
|
||||
showOrigin: { type: Boolean, required: true },
|
||||
firstChar: { type: [String, null], default: null }
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
:node="node" tag="h4"
|
||||
block edition url
|
||||
class="mr-auto"
|
||||
:first-char="firstChar"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,7 +37,8 @@ export default {
|
||||
|
||||
props: {
|
||||
node: { type: Object, required: true },
|
||||
mode: { type: String, required: true }
|
||||
mode: { type: String, required: true },
|
||||
firstChar: { type: [String, null], default: null }
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
>
|
||||
<slot name="default" />
|
||||
<span>
|
||||
<strong>{{ toCommaList(node.authors) }}</strong>,
|
||||
<strong>{{ authors }}</strong>,
|
||||
<button-url v-if="url && node.piece && node.piece.url" :link="node.piece" />
|
||||
<button-url v-if="url && node.link && node.link.url" :link="node.link" />
|
||||
</span>
|
||||
@@ -44,7 +44,8 @@ export default {
|
||||
block: { type: Boolean, default: false },
|
||||
edition: { type: Boolean, default: false },
|
||||
noDate: { type: Boolean, default: false },
|
||||
url: { type: Boolean, default: false }
|
||||
url: { type: Boolean, default: false },
|
||||
firstChar: { type: [String, null], default: null }
|
||||
},
|
||||
|
||||
data () {
|
||||
@@ -52,6 +53,20 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
authors () {
|
||||
if (!this.firstChar || this.node.authors.length < 2) return toCommaList(this.node.authors)
|
||||
const authors = [...this.node.authors].sort((a, b) => a.last_name.localeCompare(b.last_name))
|
||||
const first = this.node.authors.filter(author => author.last_name.startsWith(this.firstChar))
|
||||
first.forEach((author) => {
|
||||
const index = authors.indexOf(author)
|
||||
authors.splice(index, 1)
|
||||
authors.unshift(author)
|
||||
})
|
||||
return toCommaList(authors)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
trim,
|
||||
toCommaList,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
@open-node="$emit('open-node', $event)"
|
||||
@open-child="$emit('open-node', { parentId: node.id, ...$event })"
|
||||
:style="`--opacity: ${getStrangenessOpacity(strangeness, node)};`"
|
||||
:first-char="char"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -272,8 +272,7 @@ export default {
|
||||
return [group[0], group[1].sort((a, b) => {
|
||||
const prev = a.last_name.toLowerCase()
|
||||
const next = b.last_name.toLowerCase()
|
||||
if (prev === next) return 0
|
||||
return prev < next ? -1 : 1
|
||||
return prev.localeCompare(next)
|
||||
}).map(node => node.node)]
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user