Skip to content

Commit

Permalink
Adds a quick way to mark an entry as "not related"
Browse files Browse the repository at this point in the history
Uses existing ignore suggestion mechanism behind the scenes
  • Loading branch information
JohnathonKoster committed Sep 16, 2024
1 parent 76c0f54 commit fc10552
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
34 changes: 34 additions & 0 deletions resources/js/components/links/RelatedContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,43 @@
<template slot="cell-score" slot-scope="{ row: item }">
<span>{{ item.score.toFixed(2) }}</span>
</template>
<template slot="actions" slot-scope="{ row: related }">
<dropdown-list>
<dropdown-item text="Not Related" class="warning" @click="ignoringSuggestion = makeSuggestion(related)" />
</dropdown-list>
</template>
</data-list-table>
</div>
</div>
</data-list>

<IgnoreConfirmation
:suggestion="ignoringSuggestion"
:entry-id="entry"
@closed="ignoringSuggestion = null"
mode="related"
:site="site"
@saved="handleRelatedContentIgnored"
></IgnoreConfirmation>
</div>
</template>

<script>
import IgnoreConfirmation from './suggestions/IgnoreConfirmation.vue';

export default {
props: [
'entry',
'site',
],

components: {
IgnoreConfirmation,
},

data() {
return {
ignoringSuggestion: null,
columns: [
{ label: 'Entry', field: 'entry.title' },
{ label: 'Score', field: 'score' },
Expand All @@ -56,6 +78,18 @@ export default {

methods: {

makeSuggestion(related) {
return {
phrase: '',
entry: related.entry.id,
};
},

handleRelatedContentIgnored() {
this.ignoringSuggestion = null;
this.loadData();
},

loadData() {
this.loading = true;

Expand Down
1 change: 1 addition & 0 deletions resources/js/components/links/SuggestionsListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
:suggestion="ignoringSuggestion"
:entry-id="entry"
@closed="ignoringSuggestion = null"
mode="suggestion"
:site="site"
@saved="handleSuggestionIgnored"
></IgnoreConfirmation>
Expand Down
26 changes: 22 additions & 4 deletions resources/js/components/links/suggestions/IgnoreConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
>
<div class="confirmation-modal flex flex-col h-full">
<div class="text-lg font-medium p-4 pb-0">
Ignore Suggestion
{{ title }}
</div>
<div class="flex-1 px-4 py-6 text-gray dark:text-dark-150">
<div class="px-2">
<div class="publish-fields @container">
<div class="form-group publish-field w-full">
<div class="form-group publish-field w-full" v-if="mode === 'suggestion'">
<div class="field-inner">
<label class="publish-field-label">
<span class="rtl:ml-1 ltr:mr-1 v-popper--has-tooltip">Action</span>
Expand All @@ -25,6 +25,10 @@
></select-input>
</div>

<div class="form-group publish-field w-full" v-if="mode === 'related'">
<p>Do not suggest this entry as related:</p>
</div>

<div class="form-group publish-field w-full">
<div class="field-inner">
<label class="publish-field-label">
Expand All @@ -48,7 +52,7 @@
v-text="__('Cancel')" />
<button class="rtl:mr-4 ltr:ml-4 btn-danger"
@click="save"
v-text="__('Ignore')"
v-text="confirm"
/>
</div>
</div>
Expand All @@ -62,6 +66,7 @@ export default {
'entryId',
'site',
'suggestion',
'mode',
],
data() {
Expand Down Expand Up @@ -92,6 +97,18 @@ export default {
};
},
computed: {
title() {
return this.mode === 'suggestion' ? 'Ignore Suggestion' : 'Ignore Related Content';
},
confirm() {
return this.mode === 'suggestion' ? 'Ignore Suggestion' : 'Ignore Entry';
},
},
methods: {
updateAction(val) {
Expand All @@ -110,7 +127,7 @@ export default {
save() {
const payload = {
site: this.site,
action: this.action,
action: this.mode === 'related' ? 'ignore_entry' : this.action,
scope: this.scope,
phrase: this.suggestion.phrase,
entry: this.entryId,
Expand All @@ -124,5 +141,6 @@ export default {
},
},
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function create(IgnoreSuggestionRequest $request)
$this->linksRepository->ignoreSuggestion(new IgnoredSuggestion(
$data['action'],
$data['scope'],
$data['phrase'],
$data['phrase'] ?? '',
$data['entry'],
$data['ignored_entry'],
$data['site']
Expand Down

0 comments on commit fc10552

Please sign in to comment.