Skip to content

Commit

Permalink
Merge pull request #1055 from PlanoramaEvents/gail
Browse files Browse the repository at this point in the history
PLAN-911 UI people matching
  • Loading branch information
balen authored Jun 6, 2024
2 parents 6d74680 + eeda978 commit 89a90dd
Show file tree
Hide file tree
Showing 46 changed files with 1,181 additions and 174 deletions.
6 changes: 5 additions & 1 deletion app/controllers/concerns/resource_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def collection
.where(collection_where)
# anpther where?

q = q.distinct if join_tables && !join_tables.empty?
q = q.distinct if (join_tables && !join_tables.empty?) || make_distinct?

q = q.order(order_string)

Expand Down Expand Up @@ -762,6 +762,10 @@ def array_col?(col_name:)
false
end

def make_distinct?
false
end

def permitted_params()
_permitted_params(model: nil)
end
Expand Down
71 changes: 71 additions & 0 deletions app/controllers/person_sync_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,66 @@ class PersonSyncDataController < ResourceController
DEFAULT_SORTBY = 'name_sort_by'
DEFAULT_ORDER = 'asc'.freeze

#
#
#
def match
model_class.transaction do
authorize model_class, policy_class: policy_class

reg_id = params[:reg_id] if params[:reg_id]
person_id = params[:person_id] if params[:person_id]

# one of 'assisted' or 'manual'
reg_match = params[:reg_match] if params[:reg_match]

raise "Type of match should be 'assisted' or 'manual' you gave '#{reg_match}'" unless ['assisted', 'manual'].include? reg_match
raise "No reg id, person id, or match type specified" unless reg_id && person_id && reg_match

# Get the reg sync data
datum = RegistrationSyncDatum.find_by reg_id: reg_id

# Get the person
person = Person.find person_id

# Update the person with the reg data
IdentityService.clear_person_reg_info(person: person);
IdentityService.update_reg_info(person: person, details: datum.raw_info, reg_match: reg_match)

render status: :ok,
json: { message: "Matched" }.to_json,
content_type: 'application/json'
end
end

#
# Method to dismiss a match
# POST request, parameters are reg_id and person_id
#
def dismiss_match
model_class.transaction do
authorize model_class, policy_class: policy_class

reg_id = params[:reg_id] if params[:reg_id]
person_id = params[:person_id] if params[:person_id]

raise "No reg id or person id specified" unless reg_id && person_id

existing = DismissedRegSyncMatch.find_by reg_id: reg_id, person_id: person_id

if !existing
DismissedRegSyncMatch.create!({
reg_id: reg_id,
person_id: person_id
})
end

render status: :ok,
json: { message: "Dismissed Match" }.to_json,
content_type: 'application/json'
end
end

# by default get the data that is not already mapped to a person
def default_scope(query: nil)
return nil unless query
Expand All @@ -15,12 +75,23 @@ def default_scope(query: nil)
.where('registration_sync_data.reg_id in (select reg_id from registration_map_counts)')
end

def select_fields
PersonSyncDatum.select(
::PersonSyncDatum.arel_table[Arel.star],
'name_sort_by'
)
end

def serializer_includes
[
:registration_sync_data
]
end

def make_distinct?
true
end

def includes
[
:email_addresses,
Expand Down
33 changes: 18 additions & 15 deletions app/controllers/registration_sync_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ class RegistrationSyncDataController < ResourceController
DEFAULT_SORTBY = 'registration_sync_data.name'
DEFAULT_ORDER = 'asc'.freeze

def sync_statistics
authorize current_person, policy_class: policy_class
status = RegistrationSyncStatus.order('created_at desc').first

result = status ? status.result : {}

render status: :ok, json: result.to_json, content_type: 'application/json'
end

def synchronize
authorize current_person, policy_class: policy_class

Expand Down Expand Up @@ -37,24 +46,18 @@ def people
content_type: 'application/json'
end

# by default get the data that is not already mapped to a person
def default_scope(query: nil)
return nil unless query

# People that have a potential mapping and not already mapped
query.where('reg_id not in (select reg_id from people where reg_id is not null)')
.where('reg_id in (select reg_id from registration_map_counts)')
end

def serializer_includes
[
:people
:matched_person
]
end

def includes
[
:people
]
end
# # by default get the data that is not already mapped to a person
# def default_scope(query: nil)
# return nil unless query

# # People that have a potential mapping and not already mapped
# query.where('reg_id not in (select reg_id from people where reg_id is not null)')
# .where('reg_id in (select reg_id from registration_map_counts)')
# end
end
31 changes: 22 additions & 9 deletions app/javascript/components/icon_button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
<span :id="spanId" class="d-inline-block" :tabindex="disabled ? 0 : -1">
<b-button
:size="size"
:class="['mx-1', {'px-0': variant === 'link', 'px-2': variant === 'primary'}]"
:variant="variant"
:class="['mx-1', {'px-0': computedVariant === 'link', 'px-2': computedVariant === 'primary'}]"
:variant="computedVariant"
v-on="$listeners"
:id="id"
:disabled="disabled"
:style="style"
:title="tooltip"
v-b-tooltip.bottom
v-bind="$attrs"
v-b-modal="modal"
>
<slot v-bind="{variant: iconVariant}">
<b-icon v-if="icon" :icon="icon" :variant="iconVariant"></b-icon>
<slot v-bind="{variant: iconVariant, disabled}">
<b-icon v-if="icon" :icon="icon" :variant="iconVariant" :class="{'text-muted': disabled}"></b-icon>
</slot>
</b-button>
</span>
Expand All @@ -35,6 +37,10 @@ export default {
type: String,
required: false
},
variant: {
type: String,
default: 'primary'
},
disabledTooltip: {
type: String,
default: "This button is disabled"
Expand All @@ -51,23 +57,30 @@ export default {
type: String,
default: "sm"
},
tooltip: {
type: String,
},
modal: {
type: String,
}
},
computed: {
variant() {
computedVariant() {
switch(this.background) {
case "none":
return "link";
case "default":
return "primary";
case "danger":
return "danger";
}
},
iconVariant() {
switch(this.variant) {
switch(this.computedVariant) {
case "link":
return "primary";
case "primary": {
return this.disabled ? undefined : this.variant;
case "primary":
return undefined;
}
}
},
spanId() {
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/constants/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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 bold = (text) => (h) => h('strong', {}, text);

module.exports = {
// login page
Expand Down Expand Up @@ -274,6 +275,9 @@ module.exports = {
global_diaspora: "Member of the global diaspora",
non_anglophone: "Represent something other than a purely anglophone perspective",
excluded_demographic_categories: "Participant's demographic categories that should not be discussed on panels that include them",
registered: "Registered",
registration_type: "Registration Type",
reg_attending_status: "Registration Attending Status",
},
PERSON_SAVE_SUCCESS: "Profile record saved successfully",
PERSON_NEVER_LOGGED_IN: "Never logged in",
Expand Down Expand Up @@ -362,4 +366,10 @@ module.exports = {
PROFILE_LINK_EXPLAINATION_1: "When you link your Planorama account to your registration account they are matched, and you will be asked to confirm the correct registration account.",
PROFILE_LINK_EXPLAINATION_2: "You will continue to log in to Planorama using the password you created, not your registration login details.",
PROFILE_LINK_EXPLAINATION_TITLE: "What does it mean to link to registration?",
REG_ID_SEARCH_PLACEHOLDER: "Search for a ticket number.",
REG_ID_FOUND: "Found a match in the registration database",
REG_ID_NOT_FOUND: "No results found. Please check your input.",
REG_ID_UNLINK_BUTTON: "Unlink Current Registration",
REG_ID_UNLINK_CONFIRMATION_TITLE: "",
REG_ID_UNLINK_CONFIRMATION_TEXT: (name, number) => `This will unlink ${name} from Ticket Number ${number}.`,
}
18 changes: 17 additions & 1 deletion app/javascript/integrations/clyde_settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<b-form-group label-cols="auto" label="Enable Clyde" class="configuration enable">
<b-form-checkbox switch v-model="clydeEnabled" @change="patchClydeConfig()"></b-form-checkbox>
</b-form-group>
<b-button variant="primary" size="sm" v-b-modal.confirm-reg-sync class="ml-2">Registration Synchronize</b-button>
<b-form-group label-cols="auto" label="Use Clyde as Registration Integration" class="configuration enable ml-2">
<b-form-checkbox switch v-model="clydeRegistration" @change="patchClydeConfig()" :disabled="!clydeEnabled"></b-form-checkbox>
</b-form-group>
Expand All @@ -22,15 +23,30 @@
</b-form-group>
</div>
</div>
<plano-modal id="confirm-reg-sync" @ok="synchronizeSchedule()">
<template #modal-title>Synchonize Registration Info</template>
Only bad things will happen if you do this. Also this text needs to be in a strings file.
</plano-modal>
</div>
</template>

<script>
import { clydeMixin } from './clyde.mixin'
import PlanoModal from '@/components/plano_modal.vue';
import { toastMixin } from '@/mixins';
import { http } from '@/http';
export default {
name: "ClydeSettings",
mixins: [clydeMixin],
mixins: [clydeMixin, toastMixin],
components: {
PlanoModal
},
methods: {
synchronizeSchedule() {
this.toastPromise(http.get('/registration_sync_data/synchronize'), "Succesfully requested registration sync")
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/navbar/side-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<b-nav-item to="/profile" active-class="active"><b-icon-person-badge class="mr-2"></b-icon-person-badge>Profile</b-nav-item>
<b-nav-item v-if="currentUserIsAdmin" to="/admin" active-class="active"><b-icon-minecart-loaded class="mr-2"></b-icon-minecart-loaded>Admin</b-nav-item>
<b-nav-item v-if="currentUserIsAdmin" to="/admin-configurations" active-class="active"><b-icon-minecart-loaded class="mr-2"></b-icon-minecart-loaded>Configurations</b-nav-item>
<b-nav-item v-if="currentUserIsAdmin" to="/admin-registrations" active-class="active"><b-icon-minecart-loaded class="mr-2"></b-icon-minecart-loaded>Registrations</b-nav-item>
<!-- <b-nav-item v-if="currentUserIsAdmin" to="/admin-registrations" active-class="active"><b-icon-minecart-loaded class="mr-2"></b-icon-minecart-loaded>Registrations</b-nav-item> -->
</b-nav>
</div>
</template>
Expand Down
Loading

0 comments on commit 89a90dd

Please sign in to comment.