Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/RocketChat#751' into protocols
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/rocketchat-i18n/i18n/ru.i18n.json
  • Loading branch information
shedoev committed Oct 27, 2020
2 parents ab01b2c + 189dcf8 commit cd65522
Show file tree
Hide file tree
Showing 23 changed files with 763 additions and 77 deletions.
14 changes: 8 additions & 6 deletions app/councils/client/views/Council.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo, useState } from 'react';
import { Box, Button, Field, Label, Table } from '@rocket.chat/fuselage';
import { Box, Button, Field, Label, Table, TextInput } from '@rocket.chat/fuselage';

import Page from '../../../../client/components/basic/Page';
import { useTranslation } from '../../../../client/contexts/TranslationContext';
Expand All @@ -12,7 +12,7 @@ import { useMethod } from '../../../../client/contexts/ServerContext';
import { settings } from '../../../../app/settings/client';
import moment from 'moment';

const style = { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' };
const style = { textOverflow: 'ellipsis', overflow: 'hidden' };

export function CouncilPage() {
const t = useTranslation();
Expand Down Expand Up @@ -61,9 +61,11 @@ export function CouncilPage() {
mediaQuery && <Th key={'createdAt'} style={{ width: '190px' }} color='default'>{t('Joined_at')}</Th>
], [mediaQuery]);

const styleTableRow = { 'word-wrap': 'break-word' };

const renderRow = (invitedUser) => {
const iu = invitedUser;
return <Table.Row key={iu._id} tabIndex={0} role='link' action>
return <Table.Row key={iu._id} style={styleTableRow} tabIndex={0} role='link' action>
<Table.Cell fontScale='p1' style={style} color='default'>{iu.lastName} {iu.firstName} {iu.patronymic}</Table.Cell>
<Table.Cell fontScale='p1' style={style} color='default'>{iu.position}</Table.Cell>
{ mediaQuery && <Table.Cell fontScale='p1' style={style} color='default'>{iu.contactPersonLastName} {iu.contactPersonFirstName} {iu.contactPersonPatronymicName}</Table.Cell>}
Expand All @@ -81,13 +83,13 @@ export function CouncilPage() {
<Field mbe='x8'>
<Field.Label>{t('Date')}</Field.Label>
<Field.Row>
<Box is='span' fontScale='p1'>{formatDateAndTime(data.d)}</Box>
<TextInput readonly is='span' fontScale='p1'>{formatDateAndTime(data.d)}</TextInput>
</Field.Row>
</Field>
<Field mbe='x8'>
<Field.Label>{t('Description')}</Field.Label>
<Field.Row>
<Box is='span' fontScale='p1'>{data.desc}</Box>
<TextInput readonly is='span' fontScale='p1'>{data.desc}</TextInput>
</Field.Row>
</Field>
<Field mbe='x8'>
Expand All @@ -99,7 +101,7 @@ export function CouncilPage() {
<Field mbe='x8'>
<Field.Row>
<Field.Label>{t('Council_Invited_Users')}</Field.Label>
<Button small onClick={downloadCouncilParticipants(councilId)} aria-label={t('Download')}>
<Button small color='var(--button-primary-text-color)' backgroundColor='var(--button-primary-background)' className='rc-button rc-button--small' onClick={downloadCouncilParticipants(councilId)} aria-label={t('Download')}>
{t('Download_Council_Participant_List')}
</Button>
</Field.Row>
Expand Down
4 changes: 3 additions & 1 deletion app/councils/client/views/Councils.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ export function Councils({

const formatDateAndTime = useFormatDateAndTime();

const styleTr = { 'border-bottom-width': '10px', 'border-bottom-color': 'white' };

const renderRow = (council) => {
const { _id, d: date, desc, ts } = council;
return <Table.Row key={_id} tabIndex={0} role='link' action backgroundColor={colorBackgroundCouncil(date)}>
return <Table.Row key={_id} tabIndex={0} role='link' action style={styleTr} backgroundColor={colorBackgroundCouncil(date)}>
<Table.Cell fontScale='p1' onClick={onClick(_id)} color={colorTextCouncil(date)}>{formatDateAndTime(date)} {statusCouncil(date)}</Table.Cell>
<Table.Cell fontScale='p1' onClick={onClick(_id)} color={colorTextCouncil(date)}><Box withTruncatedText>{desc}</Box></Table.Cell>
{ mediaQuery && <Table.Cell fontScale='p1' onClick={onClick(_id)} color={colorTextCouncil(date)}>{formatDateAndTime(ts)}</Table.Cell>}
Expand Down
4 changes: 3 additions & 1 deletion app/councils/client/views/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ export function CouncilsPage() {
setCache(new Date());
}, []);

const styleButton = { 'font-size': '1.3rem', 'background-color': 'var(--button-primary-background)', color: 'var(--button-primary-text-color)' };

return <Page flexDirection='row'>
<Page>
<Page.Header title={t('Councils')}>
<Button small onClick={handleHeaderButtonClick('new')} aria-label={t('New')}>
<Button style={styleButton} small onClick={handleHeaderButtonClick('new')} aria-label={t('New')}>
<Icon name='plus'/>
</Button>
</Page.Header>
Expand Down
2 changes: 1 addition & 1 deletion app/councils/server/methods/downloadCouncilParticipants.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Meteor.methods({
},
}),
new TableCell({
children: [new Paragraph({ text: `${ value.lastName } ${ value.firstName } ${ value.patronymic }`.trim(), alignment: AlignmentType.CENTER })],
children: [new Paragraph({ text: `${ value.lastName.toUpperCase() } ${ value.firstName } ${ value.patronymic }`.trim(), alignment: AlignmentType.CENTER })],
verticalAlign: VerticalAlign.CENTER,
alignment: AlignmentType.CENTER,
width: {
Expand Down
61 changes: 61 additions & 0 deletions app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,57 @@ function validateUserEditing(userId, userData) {
}
}

const handleOrganization = (updateUser, organization) => {
if (organization) {
if (organization.trim()) {
if (typeof organization !== 'string' || organization.length > 260) {
throw new Meteor.Error('error-invalid-field', 'organization', {
method: 'saveUserProfile',
});
}
updateUser.$set = updateUser.$set || {};
updateUser.$set.organization = organization;
} else {
updateUser.$unset = updateUser.$unset || {};
updateUser.$unset.organization = 1;
}
}
};

const handlePosition = (updateUser, position) => {
if (position) {
if (position.trim()) {
if (typeof position !== 'string' || position.length > 260) {
throw new Meteor.Error('error-invalid-field', 'position', {
method: 'saveUserProfile',
});
}
updateUser.$set = updateUser.$set || {};
updateUser.$set.position = position;
} else {
updateUser.$unset = updateUser.$unset || {};
updateUser.$unset.position = 1;
}
}
};

const handlePhone = (updateUser, phone) => {
if (phone) {
if (phone.trim()) {
if (typeof phone !== 'string' || phone.length > 15) {
throw new Meteor.Error('error-invalid-field', 'phone', {
method: 'saveUserProfile',
});
}
updateUser.$set = updateUser.$set || {};
updateUser.$set.phone = phone;
} else {
updateUser.$unset = updateUser.$unset || {};
updateUser.$unset.phone = 1;
}
}
};

const handleBio = (updateUser, bio) => {
if (bio) {
if (bio.trim()) {
Expand Down Expand Up @@ -263,7 +314,9 @@ export const saveUser = function(userId, userData) {
const updateUser = {
$set: {
roles: userData.roles || ['user'],
surname: userData.surname,
...typeof userData.name !== 'undefined' && { name: userData.name },
patronymic: userData.patronymic,
settings: userData.settings || {},
},
};
Expand All @@ -276,6 +329,9 @@ export const saveUser = function(userId, userData) {
updateUser.$set['emails.0.verified'] = userData.verified;
}

handleOrganization(updateUser, userData.organization);
handlePosition(updateUser, userData.position);
handlePhone(updateUser, userData.phone);
handleBio(updateUser, userData.bio);
handleNickname(updateUser, userData.nickname);

Expand Down Expand Up @@ -312,6 +368,8 @@ export const saveUser = function(userId, userData) {
_id: userData._id,
username: userData.username,
name: userData.name,
surname: userData.surname,
patronymic: userData.patronymic,
})) {
throw new Meteor.Error('error-could-not-save-identity', 'Could not save user identity', { method: 'saveUser' });
}
Expand All @@ -336,6 +394,9 @@ export const saveUser = function(userId, userData) {
$set: {},
};

handleOrganization(updateUser, userData.organization);
handlePosition(updateUser, userData.position);
handlePhone(updateUser, userData.phone);
handleBio(updateUser, userData.bio);
handleNickname(updateUser, userData.nickname);

Expand Down
10 changes: 5 additions & 5 deletions app/lib/server/functions/saveUserIdentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function saveUserIdentity(userId, { _id, name: rawName, username: rawUser
}
}

if (typeof rawPatronymc !== 'undefined' && patronymicChanged) {
if (!setPatronymic(_id, patronymic, user)) {
return false;
}
}
// if (typeof rawPatronymc !== 'undefined' && patronymicChanged) {
// if (!setPatronymic(_id, patronymic, user)) {
// return false;
// }
// }

// if coming from old username, update all references
if (previousUsername && usernameChanged) {
Expand Down
Loading

0 comments on commit cd65522

Please sign in to comment.