Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added previous_tags setting #306

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,19 @@ public function togglePrivacy (Request $request)
$user->save();
}

/**
* Toggle a Users tagging settings
*/
public function toggleTagging (Request $request)
{
$user = Auth::user();

/* Whether to save the tags from a previous image */
$user->previous_tags = $request->previous_tags;

$user->save();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also return a response and handle it

return [
    'success' => true
];
.then(response => {
   console.log('my_action', response); 
   
    if (response.data.success)
    {
          // Handle success eg show successful event notification
          

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

}

/**
* Log the user out
*/
Expand Down
46 changes: 40 additions & 6 deletions resources/js/components/Litter/AddTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
v-click-outside="clickOutsideTag"
/>
</div>

<!-- Quantity -->
<div class="select" id="int">
<select v-model="quantity">
Expand All @@ -72,11 +71,26 @@
</div>

<br><br>

<div v-if="show_previous_tags && Object.keys(previousTags).length > 0 && show_previous_tags">
<h1>{{ $t('tags.previous-tags') }}:</h1>
xlcrr marked this conversation as resolved.
Show resolved Hide resolved
<div v-for="category in Object.keys(previousTags)">
<p>{{ getCategoryName(category) }}</p>

<div v-if="Object.keys(recentTags).length > 0 && this.annotations !== true && this.id !== 0" class="mb-5">
<transition-group name="list" class="recent-tags" tag="div" :key="category">
<div
v-for="tag in Object.keys(previousTags[category])"
class="litter-tag"
:key="tag"
@click="addRecentTag(category, tag)"
><p>{{ getTagName(category, tag) }}</p></div>
</transition-group>
</div>
<hr v-if="Object.keys(previousTags).length > 0">
</div>

<div v-if="Object.keys(recentTags).length > 0 && this.annotations !== true && this.id !== 0" class="mb-5">
<p class="mb-05">{{ $t('tags.recently-tags') }}</p>

<div v-for="category in Object.keys(recentTags)">
<p>{{ getCategoryName(category) }}</p>

Expand All @@ -90,7 +104,6 @@
</transition-group>
</div>
</div>

<div>
<button
:disabled="checkDecr"
Expand All @@ -109,7 +122,6 @@
@click="incr"
>+</button>
</div>

<br>

<button
Expand Down Expand Up @@ -197,6 +209,11 @@ export default {
};
},
computed: {

//whether the user wants to show previous tags. return type: boolean
show_previous_tags(){
return this.user.previous_tags == 1;
xlcrr marked this conversation as resolved.
Show resolved Hide resolved
},
/**
* Litter tags for all categories, used by the Search field
*/
Expand Down Expand Up @@ -323,6 +340,14 @@ export default {
return this.$store.state.litter.recentTags;
},

/**
* The previous tags the user applied
*/
previousTags ()
{
return this.$store.state.litter.previousTags;
},

/**
* Get / Set the current tag (category -> tag)
*/
Expand Down Expand Up @@ -352,6 +377,14 @@ export default {
};
});
},

/**
* Currently authenticated user
*/
user ()
{
return this.$store.state.user.user;
},
},
methods: {

Expand Down Expand Up @@ -543,6 +576,7 @@ export default {
*/
async submit ()
{
// this.previousTags = (this.$store.state.litter.tags[this.id] || {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this or not? If its not needed it can be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we do. When you click the submit button, then it stores the tags you used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it meant to be commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of it. My bad.

this.processing = true;

let action = '';
Expand All @@ -561,7 +595,7 @@ export default {
await this.$store.dispatch(action);

this.processing = false;
}
},
}
};
</script>
Expand Down
1 change: 1 addition & 0 deletions resources/js/langs/de/settings/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"littercoin": "Littercoin (LTRX)",
"presence": "Presence",
"emails": "Emails",
"tagging": "Tagging",
"show-flag": "Show Flag",
"teams": "Teams"
}
4 changes: 3 additions & 1 deletion resources/js/langs/de/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import password from './password.json'
import payments from './payments.json'
import presence from './presence.json'
import privacy from './privacy.json'
import tagging from './tagging.json'

export const settings = {
account,
Expand All @@ -19,5 +20,6 @@ export const settings = {
password,
payments,
presence,
privacy
privacy,
tagging
}
1 change: 1 addition & 0 deletions resources/js/langs/de/tags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"address": "Address",
"add-tag": "Add Tag",
"previous-tags": "Previous Tags",
"coordinates": "Coordinates",
"device": "Device",
"next": "Next Image",
Expand Down
1 change: 1 addition & 0 deletions resources/js/langs/en/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"success": "Success",
"error": "Error!",
"tags-added": "Success! Your tags have been added",
"tagging-updated": "Success! Tag settings have been changed",
"subscription-cancelled": "Your subscription has been cancelled",
"privacy-updated": "Your Privacy Settings have been saved",
"litter-toggled": "Picked up value updated",
Expand Down
1 change: 1 addition & 0 deletions resources/js/langs/en/settings/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"presence": "Presence",
"emails": "Emails",
"show-flag": "Show Flag",
"tagging": "Tagging",
"teams": "Teams"
}
4 changes: 3 additions & 1 deletion resources/js/langs/en/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import password from './password.json'
import payments from './payments.json'
import presence from './presence.json'
import privacy from './privacy.json'
import tagging from './tagging.json'

export const settings = {
account,
Expand All @@ -19,5 +20,6 @@ export const settings = {
password,
payments,
presence,
privacy
privacy,
tagging
}
4 changes: 4 additions & 0 deletions resources/js/langs/en/settings/tagging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tagging": "Tagging",
"show-previous-tags": "Show previously used tags"
}
1 change: 1 addition & 0 deletions resources/js/langs/en/tags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"address": "Address",
"add-tag": "Add Tag",
"previous-tags": "Previous Tags",
"coordinates": "Coordinates",
"device": "Device",
"next": "Next Image",
Expand Down
1 change: 1 addition & 0 deletions resources/js/langs/es/settings/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"presence": "Presencia",
"emails": "Corres electrónicos",
"show-flag": "Mostrar bandera",
"tagging": "Etiquetado",
"teams": "Equipos"
}
4 changes: 3 additions & 1 deletion resources/js/langs/es/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import password from './password.json'
import payments from './payments.json'
import presence from './presence.json'
import privacy from './privacy.json'
import tagging from './tagging.json'

export const settings = {
account,
Expand All @@ -19,5 +20,6 @@ export const settings = {
password,
payments,
presence,
privacy
privacy,
tagging
}
4 changes: 4 additions & 0 deletions resources/js/langs/es/settings/tagging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tagging": "etiquetado",
"show-previous-tags": "Mostrar etiquetas utilizadas anteriormente"
}
1 change: 1 addition & 0 deletions resources/js/langs/es/tags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"address": "Dirección",
"add-tag": "Añadir etiqueta",
"previous-tags": "etiquetas anteriores",
"coordinates": "Coordenadas",
"device": "Dispositivo",
"next": "Imagen siguiente",
Expand Down
3 changes: 2 additions & 1 deletion resources/js/langs/nl/settings/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"presence": "Aanwezigheid",
"emails": "Emails",
"show-flag": "Toon vlag",
"teams": "Teams"
"teams": "Teams",
"tagging": "Taggen"
}
4 changes: 3 additions & 1 deletion resources/js/langs/nl/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import password from './password.json'
import payments from './payments.json'
import presence from './presence.json'
import privacy from './privacy.json'
import tagging from './tagging.json'

export const settings = {
account,
Expand All @@ -19,5 +20,6 @@ export const settings = {
password,
payments,
presence,
privacy
privacy,
tagging
}
4 changes: 4 additions & 0 deletions resources/js/langs/nl/settings/tagging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tagging": "Taggen",
"show-previous-tags": "Eerder gebruikte tags weergeven"
}
1 change: 1 addition & 0 deletions resources/js/langs/nl/tags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"address": "Locatie",
"add-tag": "Label toevoegen",
"previous-tags": "vorige tags",
"coordinates": "Coördinaten",
"device": "Toestel",
"next": "Volgende foto",
Expand Down
3 changes: 2 additions & 1 deletion resources/js/langs/pl/settings/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"presence": "Obecność",
"emails": "E-maile",
"show-flag": "Pokaż flage",
"teams": "Drużyny"
"tagging": "Tagowanie",
"teams": "Tagowanie"
}
4 changes: 3 additions & 1 deletion resources/js/langs/pl/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import password from './password.json'
import payments from './payments.json'
import presence from './presence.json'
import privacy from './privacy.json'
import tagging from './tagging.json'

export const settings = {
account,
Expand All @@ -19,5 +20,6 @@ export const settings = {
password,
payments,
presence,
privacy
privacy,
tagging
}
4 changes: 4 additions & 0 deletions resources/js/langs/pl/settings/tagging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tagging": "Tagowanie",
"show-previous-tags": "Pokaż poprzednio używane tags"
}
1 change: 1 addition & 0 deletions resources/js/langs/pl/tags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"address": "Adres",
"add-tag": "Dodaj tag",
"previous-tags": "poprzednie tag",
"coordinates": "Współrzędne",
"device": "Urządzenie",
"next": "Następne zdjęcie",
Expand Down
4 changes: 4 additions & 0 deletions resources/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ const router = new VueRouter({
path: 'show-flag',
component: require('./views/settings/GlobalFlag').default,
},
{
path: 'tagging',
component: require('./views/settings/Tagging').default,
},
// {
// path: 'phone',
// component: require('./views/Phone').default
Expand Down
3 changes: 2 additions & 1 deletion resources/js/store/modules/litter/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export const init = {
photos: {}, // paginated photos object
tags: {}, // added tags go here -> { photoId: { smoking: { butts: 1, lighters: 2 }, alcohol: { beer_cans: 3 } }, ... };
submitting: false,
recentTags: {}
recentTags: {},
previousTags: {}
};
1 change: 1 addition & 0 deletions resources/js/store/modules/litter/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const mutations = {
*/
clearTags (state, photoId)
{
state.previousTags = state.tags[photoId] || {}
if (photoId !== null) {
delete state.tags[photoId];
} else {
Expand Down
Loading