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 }"
|
v-bind="{ node, mode, showOrigin }"
|
||||||
class="node-view-header"
|
class="node-view-header"
|
||||||
:class="{ scrolling: scrollValue }"
|
:class="{ scrolling: scrollValue }"
|
||||||
|
:first-char="firstChar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<node-view-body v-bind="{ node, type: nodeType, mode }" :class="{ scrolling: scrollValue }"/>
|
<node-view-body v-bind="{ node, type: nodeType, mode }" :class="{ scrolling: scrollValue }"/>
|
||||||
@@ -63,7 +64,8 @@ export default {
|
|||||||
forceType: { type: String, default: null },
|
forceType: { type: String, default: null },
|
||||||
mode: { type: String, default: 'view' },
|
mode: { type: String, default: 'view' },
|
||||||
preview: { type: Boolean, default: false },
|
preview: { type: Boolean, default: false },
|
||||||
showOrigin: { type: Boolean, default: false }
|
showOrigin: { type: Boolean, default: false },
|
||||||
|
firstChar: { type: [String, null], default: null }
|
||||||
},
|
},
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
node: { type: Object, required: true },
|
node: { type: Object, required: true },
|
||||||
mode: { type: String, required: true },
|
mode: { type: String, required: true },
|
||||||
showOrigin: { type: Boolean, required: true }
|
showOrigin: { type: Boolean, required: true },
|
||||||
|
firstChar: { type: [String, null], default: null }
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
:node="node" tag="h4"
|
:node="node" tag="h4"
|
||||||
block edition url
|
block edition url
|
||||||
class="mr-auto"
|
class="mr-auto"
|
||||||
|
:first-char="firstChar"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -36,7 +37,8 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
node: { type: Object, required: true },
|
node: { type: Object, required: true },
|
||||||
mode: { type: String, required: true }
|
mode: { type: String, required: true },
|
||||||
|
firstChar: { type: [String, null], default: null }
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
>
|
>
|
||||||
<slot name="default" />
|
<slot name="default" />
|
||||||
<span>
|
<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.piece && node.piece.url" :link="node.piece" />
|
||||||
<button-url v-if="url && node.link && node.link.url" :link="node.link" />
|
<button-url v-if="url && node.link && node.link.url" :link="node.link" />
|
||||||
</span>
|
</span>
|
||||||
@@ -44,7 +44,8 @@ export default {
|
|||||||
block: { type: Boolean, default: false },
|
block: { type: Boolean, default: false },
|
||||||
edition: { type: Boolean, default: false },
|
edition: { type: Boolean, default: false },
|
||||||
noDate: { 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 () {
|
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: {
|
methods: {
|
||||||
trim,
|
trim,
|
||||||
toCommaList,
|
toCommaList,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
@open-node="$emit('open-node', $event)"
|
@open-node="$emit('open-node', $event)"
|
||||||
@open-child="$emit('open-node', { parentId: node.id, ...$event })"
|
@open-child="$emit('open-node', { parentId: node.id, ...$event })"
|
||||||
:style="`--opacity: ${getStrangenessOpacity(strangeness, node)};`"
|
:style="`--opacity: ${getStrangenessOpacity(strangeness, node)};`"
|
||||||
|
:first-char="char"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -272,8 +272,7 @@ export default {
|
|||||||
return [group[0], group[1].sort((a, b) => {
|
return [group[0], group[1].sort((a, b) => {
|
||||||
const prev = a.last_name.toLowerCase()
|
const prev = a.last_name.toLowerCase()
|
||||||
const next = b.last_name.toLowerCase()
|
const next = b.last_name.toLowerCase()
|
||||||
if (prev === next) return 0
|
return prev.localeCompare(next)
|
||||||
return prev < next ? -1 : 1
|
|
||||||
}).map(node => node.node)]
|
}).map(node => node.node)]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user