Added relation comment. Changed relation dialog order.
This commit is contained in:
@@ -6,7 +6,7 @@ import Dialog from '#/components/dialog/dialog.vue';
|
||||
|
||||
import { get } from '#/src/api.js';
|
||||
import getPath from '#/src/get-path.js';
|
||||
import { getRelationLabel } from '#/utils/relation-labels.js';
|
||||
import { getRelationLabel, sortRelationTypes } from '#/utils/relation-labels.js';
|
||||
|
||||
const props = defineProps({
|
||||
scene: {
|
||||
@@ -30,6 +30,8 @@ const results = ref([]);
|
||||
const searching = ref(false);
|
||||
const selectedScene = ref(null);
|
||||
const selectedOption = ref(null);
|
||||
const comment = ref('');
|
||||
const commentLimit = 500; // matches the server limit
|
||||
const searchCompleted = ref(false); // only show 'no results' once a search for the current query has finished
|
||||
|
||||
let searchTimeout = null;
|
||||
@@ -37,7 +39,7 @@ let searchCount = 0;
|
||||
|
||||
// each type can be read from either side, e.g. this scene is a 'Remaster of' or 'Remastered as' the selected scene
|
||||
// symmetric types like variants read the same both ways
|
||||
const options = computed(() => props.types.flatMap(({ type, symmetric }) => (symmetric ? ['both'] : ['target', 'source']).map((direction) => ({
|
||||
const options = computed(() => sortRelationTypes(props.types, ({ type }) => type).flatMap(({ type, symmetric }) => (symmetric ? ['both'] : ['target', 'source']).map((direction) => ({
|
||||
key: `${type}-${direction}`,
|
||||
type,
|
||||
direction,
|
||||
@@ -48,7 +50,7 @@ const hasQuery = computed(() => query.value.trim().length > 0);
|
||||
const showResults = computed(() => results.value.length > 0 || (hasQuery.value && !searching.value && searchCompleted.value));
|
||||
|
||||
// derivations and compilations are released after what they're based on, the source of the relation should not predate the target
|
||||
const chronologicalTypes = ['rerelease', 'remaster', 'compilation'];
|
||||
const chronologicalTypes = ['rerelease', 'remaster', 'reedit', 'compilation'];
|
||||
const datePrecisions = { year: startOfYear, month: startOfMonth };
|
||||
|
||||
// compare at the coarsest precision of the two, a scene known only by its year isn't necessarily earlier than one from later that year
|
||||
@@ -85,7 +87,7 @@ const inversion = computed(() => {
|
||||
});
|
||||
|
||||
const canSubmit = computed(() => !!selectedScene.value && !!selectedOption.value);
|
||||
const hasChanges = computed(() => !!selectedScene.value || !!selectedOption.value);
|
||||
const hasChanges = computed(() => !!selectedScene.value || !!selectedOption.value || comment.value.trim().length > 0);
|
||||
|
||||
// accept a pasted scene ID or traxxx scene URL, the search index does not match IDs
|
||||
function getSceneId(value) {
|
||||
@@ -166,6 +168,7 @@ function addRelation() {
|
||||
sceneId: selectedScene.value.id,
|
||||
type: selectedOption.value.type,
|
||||
direction: selectedOption.value.direction,
|
||||
comment: comment.value.trim() || null,
|
||||
scene: selectedScene.value,
|
||||
});
|
||||
}
|
||||
@@ -288,6 +291,13 @@ onMounted(() => focusInput());
|
||||
</template>
|
||||
</VDropdown>
|
||||
|
||||
<input
|
||||
v-model="comment"
|
||||
:maxlength="commentLimit"
|
||||
placeholder="Optional comment"
|
||||
class="comment input"
|
||||
>
|
||||
|
||||
<p
|
||||
v-if="inversion"
|
||||
class="inversion"
|
||||
@@ -434,4 +444,8 @@ onMounted(() => focusInput());
|
||||
margin: 0;
|
||||
padding: .5rem;
|
||||
}
|
||||
|
||||
.comment {
|
||||
margin: .5rem 0 0 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user