Skip to content

Commit

Permalink
Merge pull request #930 from PlanoramaEvents/development
Browse files Browse the repository at this point in the history
v3.2.0-rc2
  • Loading branch information
Gailbear authored Feb 8, 2024
2 parents 722a7be + eabf31e commit b650a44
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/controllers/page_contents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ def paginate
false
end
end

# TODO: check delete
3 changes: 3 additions & 0 deletions app/javascript/auth/person_session.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const personSessionMixin = {
currentUserEmail() {
return this.currentUser.primary_email?.email || '';
},
currentUserLinked() {
return !!Object.keys(this.currentUser.oauth_identities).length;
},
// Need to display something if there is no email ...
// which can happen with a non-unique email from OAuth login
currentUserDisplay() {
Expand Down
39 changes: 39 additions & 0 deletions app/javascript/components/disabled_tooltip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<div class="d-inline-block">
<span :id="spanId" class="d-inline-block" :tabindex="disabled ? 0 : -1">
<slot></slot>
</span>
<b-tooltip :target="spanId" v-if="disabled" placement="bottom">{{disabledTooltip}}</b-tooltip>
</div>
</template>

<script>
import { v4 as uuidv4 } from 'uuid';
export default {
name: "DisabledTooltip",
props: {
disabledTooltip: {
type: String,
default: "This button is disabled"
},
disabled: {
type: Boolean,
default: false
},
id: {
type: String,
default: () => uuidv4()
},
},
computed: {
spanId() {
return `${this.id}-disabled-span`;
},
},
}
</script>

<style>
</style>
10 changes: 9 additions & 1 deletion app/javascript/constants/strings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const twoLines = (line1, line2) => (h) => h('p', {}, [line1, h('br'), line2]);
const errorMessage = (message) => (errorCode) => twoLines(message, `Error code: ${errorCode}`);
const titleCase = (model) => `${model.substring(0, 1).toUpperCase()}${model.substring(1)}`;
const nLines = (lines) => (h) => h('p', {}, lines.reduce((p, c) => [...p, c, h('br')], []))
const nLines = (lines) => (h) => h('p', {}, lines.reduce((p, c) => [...p, c, h('br')], []));

module.exports = {
// login page
Expand Down Expand Up @@ -266,6 +266,12 @@ module.exports = {
},
PERSON_SAVE_SUCCESS: "Profile record saved successfully",
PERSON_NEVER_LOGGED_IN: "Never logged in",
PERSON_DISABLED_LINK: "You can only link your own registration",
PERSON_DISABLED_UNLINK: "You can only unlink your own registration",
PERSON_UNLINK_SUCCESS: "Your registration account has been unlinked.",
PERSON_UNLINK_FAILURE: errorMessage("Something went wrong while unlinking your registration account."),
PERSON_UNLINK_CONFIRMATION_1: "This will unlink your registration account from your Planorama account. It will not remove your data from other convention systems. If you later choose to log in using your registration account, this link will be reestablished.",
PERSON_UNLINK_CONFIRMATION_2: "Are you sure you want to do this action?",
PERSON_CON_STATE: {
not_set: "Not Set",
applied: "Applied",
Expand All @@ -286,6 +292,8 @@ module.exports = {

PAGE_CONTENT_SAVE_SUCCESS: "Page content saved successfully",
PAGE_CONTENT_SAVE_ERROR: "Page content save failed",
PAGE_CONTENT_SUCCESS_DELETE: "Page content successfully deleted.",
PAGE_CONTENT_ERROR_DELETE: errorMessage("Page content failed to be deleted."),

SURVEY_REDIRECT: "Unfortunately due to the browser refreshing we have lost any answers you filled in. Please fill the survey out again.",
SURVEY_PUBLIC_NO_EDIT: "You cannot edit a published survey. Close the survey to enable editing.",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/navbar/bottom-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ footer {
position: absolute;
bottom: 0px;
padding: 10px;
z-index: 3000;
a {
color: white;
Expand Down
7 changes: 6 additions & 1 deletion app/javascript/page-content/page_content.mixin.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { mapGetters, mapState, mapActions } from 'vuex';
import toastMixin from '../shared/toast-mixin';
import { NEW_PAGE_CONTENT } from '@/store/page_content.store';
import { PAGE_CONTENT_SAVE_SUCCESS, PAGE_CONTENT_SAVE_ERROR } from '../constants/strings'
import { PAGE_CONTENT_SAVE_SUCCESS, PAGE_CONTENT_SAVE_ERROR, PAGE_CONTENT_SUCCESS_DELETE, PAGE_CONTENT_ERROR_DELETE } from '../constants/strings'
import modelUtilsMixin from '../store/model_utils.mixin'
import { DELETE } from "@/store/model.store"

export const pageContentMixin = {
mixins: [toastMixin, modelUtilsMixin],
methods: {
...mapActions({
new_page_content: NEW_PAGE_CONTENT
}),
// Do we need a delete ?
savePageContent(newPageContent, success_text = PAGE_CONTENT_SAVE_SUCCESS, error_text = PAGE_CONTENT_SAVE_ERROR) {
if (newPageContent.id) {
return this.save_model('page_content', newPageContent)
Expand All @@ -20,6 +22,9 @@ export const pageContentMixin = {
)
}
},
deletePageContent(itemOrId, success_text = PAGE_CONTENT_SUCCESS_DELETE, error_text = PAGE_CONTENT_ERROR_DELETE) {
return this.toastPromise(this.$store.dispatch(DELETE, { model: 'page_content', itemOrId: itemOrId }), success_text, error_text);
}
}
}

Expand Down
10 changes: 9 additions & 1 deletion app/javascript/page-content/page_content_editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
></plano-editor>
<!-- TODO - do we want a delete? -->
<b-button variant="primary" @click="saveContent">Save</b-button>

<b-button variant="secondary" @click="clearContent">Reset To Default</b-button>
</div>
</template>

Expand Down Expand Up @@ -57,6 +57,14 @@ export default {
html: ''
}
},
clearContent() {
console.debug("**** DELETE", this.content)
this.deletePageContent(this.content).then(
() => {
this.content = this.starter_content()
}
);
},
saveContent() {
let res = this.savePageContent(this.content);
res.then(
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/profile/person_details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h5>Identity</h5>
<div class="d-flex justify-content-between">
<dl-person :fields="['name', 'pseudonym']"></dl-person>
<registration-link></registration-link>
<registration-link v-if="!readOnly"></registration-link>
</div>
</div>
<div v-if="readOnly">
Expand Down Expand Up @@ -65,7 +65,7 @@
<a target="blank" href="https://www.timeanddate.com/worldclock/meeting.html">
https://www.timeanddate.com/worldclock/meeting.html
</a>
and check by specifying the date of September 1 2022 and your location as well as UTC/GMT
and check by specifying the date of first day of the convention and your location as well as UTC/GMT
</small>
</b-form-group>
</div>
Expand Down
47 changes: 35 additions & 12 deletions app/javascript/profile/registration_link.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
<template>
<div class="mr-3" v-if="registrationIntegration">
<div v-if="!selected.registration_number">
<div class="mr-3" v-if="registrationIntegration && isSelf">
<div v-if="!currentUserLinked">
<!-- Use the redirect to come back to profile -->
<form :action="registrationIntegration.endpoint + '?redirect=profile'" method="post">
<input type="hidden" v-model="csrfToken" name="authenticity_token" />
<b-button variant="info" size="sm" type="submit">Link To Registration</b-button>
<disabled-tooltip :disabled="!isSelf" :disabledTooltip="PERSON_DISABLED_LINK">
<b-button variant="info" size="sm" type="submit" :disabled="!isSelf">Link To Registration</b-button>
</disabled-tooltip>
</form>
</div>
<div v-if="selected.registration_number">
<b-button variant="link" @click="notimplemented">Unlink Registration</b-button>
<div v-if="currentUserLinked">
<disabled-tooltip :disabled="!isSelf" :disabledTooltip="PERSON_DISABLED_UNLINK">
<b-button variant="link" v-b-modal.confirmUnlink :disabled="!isSelf">Unlink Registration</b-button>
</disabled-tooltip>
<dl-person class="align-with-link pt-2" :fields="['registration_number']"></dl-person>
</div>
<b-modal id="confirmUnlink" @ok="unlinkPerson" ok-title="Yes" cancel-variant="link">
<p>{{PERSON_UNLINK_CONFIRMATION_1}}</p>
<p>{{PERSON_UNLINK_CONFIRMATION_2}}</p>
</b-modal>
</div>
</template>

<script>
import DlPerson from './dl_person.vue'
import { loginIntegrationsMixin } from '@/store/login_integrations.mixin';
import { modelMixinNoProp } from '@/mixins';
import { personModel as model } from '@/store/person.store';
import { modelMixinNoProp, personSessionMixin, toastMixin } from '@/mixins';
import { personModel as model, UNLINK_PERSON } from '@/store/person.store';
import DisabledTooltip from '@/components/disabled_tooltip.vue';
import { PERSON_DISABLED_LINK, PERSON_DISABLED_UNLINK, PERSON_UNLINK_FAILURE, PERSON_UNLINK_SUCCESS, PERSON_UNLINK_CONFIRMATION_1, PERSON_UNLINK_CONFIRMATION_2 } from '@/constants/strings';
import { mapActions } from 'vuex';
export default {
name: "RegistrationLink",
components: { DlPerson },
mixins: [loginIntegrationsMixin, modelMixinNoProp],
components: { DlPerson, DisabledTooltip },
mixins: [loginIntegrationsMixin, modelMixinNoProp, personSessionMixin, toastMixin],
data: () => ({
linked: false,
model
model,
PERSON_DISABLED_LINK,
PERSON_DISABLED_UNLINK,
PERSON_UNLINK_CONFIRMATION_1,
PERSON_UNLINK_CONFIRMATION_2,
}),
computed: {
isSelf() {
return this.currentUser.id === this.selected.id;
}
},
methods: {
notimplemented() {
window.alert("haven't done this yet.")
...mapActions({
unlinkPersonStore: UNLINK_PERSON
}),
unlinkPerson() {
this.toastPromise(this.unlinkPersonStore({person: this.selected}), PERSON_UNLINK_SUCCESS, PERSON_UNLINK_FAILURE);
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions app/javascript/store/person.store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NEW, PATCH_FIELDS } from './model.store';
import { NEW, PATCH_FIELDS, SELECT } from './model.store';
import { GET_SESSION_USER } from './person_session.store';

export const NEW_PERSON = 'NEW PERSON';
export const PATCH_PERSON_MODEL = 'PATCH_PERSON_MODEL'
export const PATCH_PERSON_MODEL = 'PATCH_PERSON_MODEL';
export const UNLINK_PERSON = 'UNLINK PERSON';

export const personModel = 'person';

Expand All @@ -21,6 +23,28 @@ export const personStore = {
...data
}
return dispatch(PATCH_FIELDS, {model: personModel, item, fields: Object.keys(data), selected: false })
},
[UNLINK_PERSON] ({dispatch, commit}, {person}) {
const model = personModel;
// limited field selection
let smallItem = {
// always include lock version so that we have optimistic locking
lock_version: person.lock_version || 0,
id: person.id,
_jv: {
type: model,
id: person.id
}
}
return new Promise((res, rej) => {
dispatch('jv/post', [smallItem, {url: `/person/${person.id}/unlink_registration`}]).then((savedModel) => {
// person should always be selected at this point so we shouldn't check, we should just select.
commit(SELECT, {model, itemOrId: savedModel});
dispatch(GET_SESSION_USER, {force: true}).then(() => {
res(savedModel);
});
}).catch(rej);
});
}
},
selected: {
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/stylesheets/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,8 @@ body {
.flex-basis-50 {
flex-basis: 50%;
}

// make disabled link buttons italic
.btn-link:disabled, .btn-link.disabled {
font-style: italic;
}
2 changes: 1 addition & 1 deletion app/services/identity_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def self.create_identity_from_clyde(details:)
raise "Person already exists with that email" if addr

# Otherwise we create a new person, if the email is already used as prime we can not set it as the default
person = create_person_from_clyde(details: details, identity: identity, email_is_default: addr.nil?)
person = create_person_from_clyde(details: details, identity: identity)

# And associate them with the Clyde Identity
identity.person = person
Expand Down

0 comments on commit b650a44

Please sign in to comment.