mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-12 06:54:19 +01:00
(api) rename user related models to use the _attributes naming convention
This commit is contained in:
parent
7a6fe34b90
commit
555ee11d35
@ -16,13 +16,13 @@ export const Avatar: React.FC<AvatarProps> = ({ user, className }) => {
|
|||||||
* Check if the provided user has a configured avatar
|
* Check if the provided user has a configured avatar
|
||||||
*/
|
*/
|
||||||
const hasAvatar = (): boolean => {
|
const hasAvatar = (): boolean => {
|
||||||
return !!user?.profile?.user_avatar?.attachment_url;
|
return !!user?.profile_attributes?.user_avatar_attributes?.attachment_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`avatar ${className || ''}`}>
|
<div className={`avatar ${className || ''}`}>
|
||||||
{!hasAvatar() && <img src={noAvatar} alt="avatar placeholder"/>}
|
{!hasAvatar() && <img src={noAvatar} alt="avatar placeholder"/>}
|
||||||
{hasAvatar() && <img src={user.profile.user_avatar.attachment_url} alt="user's avatar"/>}
|
{hasAvatar() && <img src={user.profile_attributes.user_avatar_attributes.attachment_url} alt="user's avatar"/>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { react2angular } from 'react2angular';
|
import { react2angular } from 'react2angular';
|
||||||
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
|
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
|
||||||
|
import { isNil as _isNil } from 'lodash';
|
||||||
import { User } from '../../models/user';
|
import { User } from '../../models/user';
|
||||||
import { IApplication } from '../../models/application';
|
import { IApplication } from '../../models/application';
|
||||||
import { Loader } from '../base/loader';
|
import { Loader } from '../base/loader';
|
||||||
@ -33,7 +34,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
|
|||||||
const { handleSubmit, register, control, formState } = useForm<User>({ defaultValues: { ...user } });
|
const { handleSubmit, register, control, formState } = useForm<User>({ defaultValues: { ...user } });
|
||||||
const output = useWatch<User>({ control });
|
const output = useWatch<User>({ control });
|
||||||
|
|
||||||
const [isOrganization, setIsOrganization] = React.useState<boolean>(user.invoicing_profile.organization !== null);
|
const [isOrganization, setIsOrganization] = React.useState<boolean>(!_isNil(user.invoicing_profile_attributes.organization_attributes));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback triggered when the form is submitted: process with the user creation or update.
|
* Callback triggered when the form is submitted: process with the user creation or update.
|
||||||
@ -115,7 +116,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
|
|||||||
id="invoicing_profile_attributes.organization"
|
id="invoicing_profile_attributes.organization"
|
||||||
label={t('app.shared.user_profile_form.declare_organization')}
|
label={t('app.shared.user_profile_form.declare_organization')}
|
||||||
tooltip={t('app.shared.user_profile_form.declare_organization_help')}
|
tooltip={t('app.shared.user_profile_form.declare_organization_help')}
|
||||||
defaultValue={user.invoicing_profile.organization !== null}
|
defaultValue={isOrganization}
|
||||||
onChange={setIsOrganization} />
|
onChange={setIsOrganization} />
|
||||||
{isOrganization && <div className="organization-fields">
|
{isOrganization && <div className="organization-fields">
|
||||||
<FormInput id="invoicing_profile_attributes.organization_attributes.id"
|
<FormInput id="invoicing_profile_attributes.organization_attributes.id"
|
||||||
|
@ -344,14 +344,14 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('calendar') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('calendar') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'calendar' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'calendar' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('calendar') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('calendar') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -369,8 +369,8 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
|
|||||||
* @return {string} 'male' or 'female'
|
* @return {string} 'male' or 'female'
|
||||||
*/
|
*/
|
||||||
const getGender = function (user) {
|
const getGender = function (user) {
|
||||||
if (user.statistic_profile) {
|
if (user.statistic_profile_attributes) {
|
||||||
if (user.statistic_profile.gender === 'true') { return 'male'; } else { return 'female'; }
|
if (user.statistic_profile_attributes.gender === 'true') { return 'male'; } else { return 'female'; }
|
||||||
} else { return 'other'; }
|
} else { return 'other'; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,14 +473,14 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state',
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('events') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('events') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'events' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'events' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('events') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('events') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1012,14 +1012,14 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('invoices') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('invoices') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'invoices' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'invoices' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settings.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('invoices') < 0) {
|
if (settings.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('invoices') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -569,14 +569,14 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('members') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('members') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'members' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'members' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('members') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('members') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -896,7 +896,7 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state',
|
|||||||
CSRF.setMetaTags();
|
CSRF.setMetaTags();
|
||||||
|
|
||||||
// init the birthdate to JS object
|
// init the birthdate to JS object
|
||||||
$scope.user.statistic_profile.birthday = moment($scope.user.statistic_profile.birthday).toDate();
|
$scope.user.statistic_profile_attributes.birthday = moment($scope.user.statistic_profile_attributes.birthday).toDate();
|
||||||
|
|
||||||
// the user subscription
|
// the user subscription
|
||||||
if (($scope.user.subscribed_plan != null) && ($scope.user.subscription != null)) {
|
if (($scope.user.subscribed_plan != null) && ($scope.user.subscription != null)) {
|
||||||
@ -946,18 +946,18 @@ Application.Controllers.controller('NewMemberController', ['$scope', '$state', '
|
|||||||
// Default member's profile parameters
|
// Default member's profile parameters
|
||||||
$scope.user = {
|
$scope.user = {
|
||||||
plan_interval: '',
|
plan_interval: '',
|
||||||
invoicing_profile: {},
|
invoicing_profile_attributes: {},
|
||||||
statistic_profile: {}
|
statistic_profile_attributes: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback when the admin check/uncheck the box telling that the new user is an organization.
|
// Callback when the admin check/uncheck the box telling that the new user is an organization.
|
||||||
// Disable or enable the organization fields in the form, accordingly
|
// Disable or enable the organization fields in the form, accordingly
|
||||||
$scope.toggleOrganization = function () {
|
$scope.toggleOrganization = function () {
|
||||||
if ($scope.user.organization) {
|
if ($scope.user.organization) {
|
||||||
if (!$scope.user.invoicing_profile) { $scope.user.invoicing_profile = {}; }
|
if (!$scope.user.invoicing_profile_attributes) { $scope.user.invoicing_profile_attributes = {}; }
|
||||||
$scope.user.invoicing_profile.organization = {};
|
$scope.user.invoicing_profile_attributes.organization_attributes = {};
|
||||||
} else {
|
} else {
|
||||||
$scope.user.invoicing_profile.organization = undefined;
|
$scope.user.invoicing_profile_attributes.organization_attributes = undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,14 +142,14 @@ Application.Controllers.controller('OpenAPIClientsController', ['$scope', 'clien
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('open-api') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('open-api') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'open-api' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'open-api' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, and if the display behavior is not configured to manual triggering only, show the tour now
|
// if the user has never seen the tour, and if the display behavior is not configured to manual triggering only, show the tour now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('open-api') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('open-api') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -740,14 +740,14 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state',
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('pricing') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('pricing') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'pricing' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'pricing' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('pricing') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('pricing') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -253,14 +253,14 @@ Application.Controllers.controller('AdminProjectsController', ['$scope', '$state
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('projects') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('projects') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'projects' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'projects' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('projects') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('projects') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -454,14 +454,14 @@ Application.Controllers.controller('SettingsController', ['$scope', '$rootScope'
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('settings') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('settings') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'settings' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'settings' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if ($scope.allSettings.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('settings') < 0) {
|
if ($scope.allSettings.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('settings') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -522,10 +522,10 @@ Application.Controllers.controller('SettingsController', ['$scope', '$rootScope'
|
|||||||
if (newValue === oldValue) return;
|
if (newValue === oldValue) return;
|
||||||
|
|
||||||
if (newValue === 'session') {
|
if (newValue === 'session') {
|
||||||
$scope.currentUser.profile.tours = Fablab.sessionTours;
|
$scope.currentUser.profile_attributes.tours = Fablab.sessionTours;
|
||||||
} else if (newValue === 'once') {
|
} else if (newValue === 'once') {
|
||||||
Member.get({ id: $scope.currentUser.id }, function (user) {
|
Member.get({ id: $scope.currentUser.id }, function (user) {
|
||||||
$scope.currentUser.profile.tours = user.profile.tours;
|
$scope.currentUser.profile_attributes.tours = user.profile_attributes.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -387,14 +387,14 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state',
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('statistics') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('statistics') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'statistics' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'statistics' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('statistics') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('statistics') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -391,14 +391,14 @@ Application.Controllers.controller('TrainingsAdminController', ['$scope', '$stat
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('trainings') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('trainings') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'trainings' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'trainings' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('trainings') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('trainings') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ Application.Controllers.controller('DashboardController', ['$scope', 'memberProm
|
|||||||
const filterNetworks = function () {
|
const filterNetworks = function () {
|
||||||
const networks = [];
|
const networks = [];
|
||||||
for (const network of Array.from(SocialNetworks)) {
|
for (const network of Array.from(SocialNetworks)) {
|
||||||
if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) {
|
if ($scope.user.profile_attributes[network] && ($scope.user.profile_attributes[network].length > 0)) {
|
||||||
networks.push(network);
|
networks.push(network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,14 +296,14 @@ Application.Controllers.controller('HomeController', ['$scope', '$transition$',
|
|||||||
});
|
});
|
||||||
// on tour end, save the status in database
|
// on tour end, save the status in database
|
||||||
uitour.on('ended', function () {
|
uitour.on('ended', function () {
|
||||||
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('welcome') < 0) {
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile_attributes.tours.indexOf('welcome') < 0) {
|
||||||
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'welcome' }, function (res) {
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'welcome' }, function (res) {
|
||||||
$scope.currentUser.profile.tours = res.tours;
|
$scope.currentUser.profile_attributes.tours = res.tours;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if the user has never seen the tour, show him now
|
// if the user has never seen the tour, show him now
|
||||||
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('welcome') < 0) {
|
if (settingsPromise.feature_tour_display !== 'manual' && $scope.currentUser.profile_attributes.tours.indexOf('welcome') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -184,8 +184,8 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$scope.currentUser.profile.user_avatar = content.profile.user_avatar;
|
$scope.currentUser.profile_attributes.user_avatar_attributes = content.profile_attributes.user_avatar_attributes;
|
||||||
Auth._currentUser.profile.user_avatar = content.profile.user_avatar;
|
Auth._currentUser.profile_attributes.user_avatar_attributes = content.profile_attributes.user_avatar_attributes;
|
||||||
$scope.currentUser.name = content.name;
|
$scope.currentUser.name = content.name;
|
||||||
Auth._currentUser.name = content.name;
|
Auth._currentUser.name = content.name;
|
||||||
$scope.currentUser = content;
|
$scope.currentUser = content;
|
||||||
@ -292,7 +292,7 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
|
|||||||
CSRF.setMetaTags();
|
CSRF.setMetaTags();
|
||||||
|
|
||||||
// init the birth date to JS object
|
// init the birth date to JS object
|
||||||
$scope.user.statistic_profile.birthday = moment($scope.user.statistic_profile.birthday).toDate();
|
$scope.user.statistic_profile_attributes.birthday = moment($scope.user.statistic_profile_attributes.birthday).toDate();
|
||||||
|
|
||||||
if ($scope.activeProvider.providable_type !== 'DatabaseProvider') {
|
if ($scope.activeProvider.providable_type !== 'DatabaseProvider') {
|
||||||
$scope.preventPassword = true;
|
$scope.preventPassword = true;
|
||||||
@ -341,7 +341,7 @@ Application.Controllers.controller('ShowProfileController', ['$scope', 'memberPr
|
|||||||
const filterNetworks = function () {
|
const filterNetworks = function () {
|
||||||
const networks = [];
|
const networks = [];
|
||||||
for (const network of Array.from(SocialNetworks)) {
|
for (const network of Array.from(SocialNetworks)) {
|
||||||
if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) {
|
if ($scope.user.profile_attributes[network] && ($scope.user.profile_attributes[network].length > 0)) {
|
||||||
networks.push(network);
|
networks.push(network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,8 @@ Application.Controllers.controller('PlansIndexController', ['$scope', '$rootScop
|
|||||||
* @return {string} 'male' or 'female'
|
* @return {string} 'male' or 'female'
|
||||||
*/
|
*/
|
||||||
$scope.getGender = function (user) {
|
$scope.getGender = function (user) {
|
||||||
if (user && user.statistic_profile) {
|
if (user && user.statistic_profile_attributes) {
|
||||||
if (user.statistic_profile.gender === 'true') { return 'male'; } else { return 'female'; }
|
if (user.statistic_profile_attributes.gender === 'true') { return 'male'; } else { return 'female'; }
|
||||||
} else { return 'other'; }
|
} else { return 'other'; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ Application.Controllers.controller('CompleteProfileController', ['$scope', '$roo
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$scope.user.profile.user_avatar = content.profile.user_avatar;
|
$scope.user.profile_attributes.user_avatar_attributes = content.profile_attributes.user_avatar_attributes;
|
||||||
Auth._currentUser.profile.user_avatar = content.profile.user_avatar;
|
Auth._currentUser.profile_attributes.user_avatar_attributes = content.profile_attributes.user_avatar_attributes;
|
||||||
$scope.user.name = content.name;
|
$scope.user.name = content.name;
|
||||||
Auth._currentUser.name = content.name;
|
Auth._currentUser.name = content.name;
|
||||||
$scope.user = content;
|
$scope.user = content;
|
||||||
@ -220,7 +220,7 @@ Application.Controllers.controller('CompleteProfileController', ['$scope', '$roo
|
|||||||
CSRF.setMetaTags();
|
CSRF.setMetaTags();
|
||||||
|
|
||||||
// init the birth date to JS object
|
// init the birth date to JS object
|
||||||
$scope.user.statistic_profile.birthday = $scope.user.statistic_profile.birthday ? moment($scope.user.statistic_profile.birthday).toDate() : undefined;
|
$scope.user.statistic_profile_attributes.birthday = $scope.user.statistic_profile_attributes.birthday ? moment($scope.user.statistic_profile_attributes.birthday).toDate() : undefined;
|
||||||
|
|
||||||
// bind fields protection with sso fields
|
// bind fields protection with sso fields
|
||||||
angular.forEach(activeProviderPromise.mapping, function (map) { $scope.preventField[map] = true; });
|
angular.forEach(activeProviderPromise.mapping, function (map) { $scope.preventField[map] = true; });
|
||||||
|
@ -19,7 +19,7 @@ export interface User {
|
|||||||
mapped_from_sso?: string[],
|
mapped_from_sso?: string[],
|
||||||
password?: string,
|
password?: string,
|
||||||
password_confirmation?: string,
|
password_confirmation?: string,
|
||||||
profile: {
|
profile_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
first_name: string,
|
first_name: string,
|
||||||
last_name: string,
|
last_name: string,
|
||||||
@ -43,27 +43,27 @@ export interface User {
|
|||||||
pinterest: string,
|
pinterest: string,
|
||||||
lastfm: string,
|
lastfm: string,
|
||||||
flickr: string,
|
flickr: string,
|
||||||
user_avatar: {
|
user_avatar_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
attachment_url: string
|
attachment_url: string
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
invoicing_profile: {
|
invoicing_profile_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
address: {
|
address_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
address: string
|
address: string
|
||||||
},
|
},
|
||||||
organization: {
|
organization_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
name: string,
|
name: string,
|
||||||
address: {
|
address_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
address: string
|
address: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
statistic_profile: {
|
statistic_profile_attributes: {
|
||||||
id: number,
|
id: number,
|
||||||
gender: string,
|
gender: string,
|
||||||
birthday: TDateISO
|
birthday: TDateISO
|
||||||
|
@ -7,40 +7,32 @@ json.need_completion member.need_completion?
|
|||||||
json.ip_address member.current_sign_in_ip.to_s
|
json.ip_address member.current_sign_in_ip.to_s
|
||||||
json.mapped_from_sso member.mapped_from_sso&.split(',')
|
json.mapped_from_sso member.mapped_from_sso&.split(',')
|
||||||
|
|
||||||
json.profile do
|
json.profile_attributes do
|
||||||
json.id member.profile.id
|
json.extract! member.profile, :id, :first_name, :last_name, :interest, :software_mastered, :phone, :website, :job
|
||||||
if member.profile.user_avatar
|
if member.profile.user_avatar
|
||||||
json.user_avatar do
|
json.user_avatar_attributes do
|
||||||
json.id member.profile.user_avatar.id
|
json.id member.profile.user_avatar.id
|
||||||
json.attachment_url "#{member.profile.user_avatar.attachment_url}?#{member.profile.user_avatar.updated_at.to_i}"
|
json.attachment_url "#{member.profile.user_avatar.attachment_url}?#{member.profile.user_avatar.updated_at.to_i}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
json.first_name member.profile.first_name
|
json.extract! member.profile, :facebook, :twitter, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr
|
||||||
json.last_name member.profile.last_name
|
|
||||||
json.interest member.profile.interest
|
|
||||||
json.software_mastered member.profile.software_mastered
|
|
||||||
json.phone member.profile.phone
|
|
||||||
json.website member.profile.website
|
|
||||||
json.job member.profile.job
|
|
||||||
json.extract! member.profile, :facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr
|
|
||||||
json.tours member.profile.tours&.split || []
|
json.tours member.profile.tours&.split || []
|
||||||
end
|
end
|
||||||
|
|
||||||
json.invoicing_profile do
|
json.invoicing_profile_attributes do
|
||||||
json.id member.invoicing_profile.id
|
json.id member.invoicing_profile.id
|
||||||
if member.invoicing_profile.address
|
if member.invoicing_profile.address
|
||||||
json.address do
|
json.address_attributes do
|
||||||
json.id member.invoicing_profile.address.id
|
json.id member.invoicing_profile.address.id
|
||||||
json.address member.invoicing_profile.address.address
|
json.address member.invoicing_profile.address.address
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if member.invoicing_profile.organization
|
if member.invoicing_profile.organization
|
||||||
json.organization do
|
json.organization_attributes do
|
||||||
json.id member.invoicing_profile.organization.id
|
json.extract! member.invoicing_profile.organization, :id, :name
|
||||||
json.name member.invoicing_profile.organization.name
|
|
||||||
if member.invoicing_profile.organization.address
|
if member.invoicing_profile.organization.address
|
||||||
json.address do
|
json.address_attributes do
|
||||||
json.id member.invoicing_profile.organization.address.id
|
json.id member.invoicing_profile.organization.address.id
|
||||||
json.address member.invoicing_profile.organization.address.address
|
json.address member.invoicing_profile.organization.address.address
|
||||||
end
|
end
|
||||||
@ -49,7 +41,7 @@ json.invoicing_profile do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
json.statistic_profile do
|
json.statistic_profile_attributes do
|
||||||
json.id member.statistic_profile.id
|
json.id member.statistic_profile.id
|
||||||
json.gender member.statistic_profile.gender.to_s
|
json.gender member.statistic_profile.gender.to_s
|
||||||
json.birthday member.statistic_profile&.birthday&.to_date&.iso8601
|
json.birthday member.statistic_profile&.birthday&.to_date&.iso8601
|
||||||
|
Loading…
x
Reference in New Issue
Block a user