-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
portal/users: add section Voicemails
- Loading branch information
Showing
8 changed files
with
195 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
EntityFormProps, | ||
FieldsetGroups, | ||
Form as DefaultEntityForm, | ||
} from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; | ||
import _ from '@irontec/ivoz-ui/services/translations/translate'; | ||
|
||
const Form = (props: EntityFormProps): JSX.Element => { | ||
const groups: Array<FieldsetGroups> = [ | ||
{ | ||
legend: _('Basic Configuration'), | ||
fields: ['enabled', 'name'], | ||
}, | ||
{ | ||
legend: _('Notification configuration'), | ||
fields: ['sendMail', 'email', 'attachSound'], | ||
}, | ||
{ | ||
legend: _('Customization'), | ||
fields: ['locution'], | ||
}, | ||
]; | ||
|
||
return <DefaultEntityForm {...props} groups={groups} />; | ||
}; | ||
|
||
export default Form; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,110 @@ | ||
import { EntityValues } from '@irontec/ivoz-ui'; | ||
import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; | ||
import EntityInterface from '@irontec/ivoz-ui/entities/EntityInterface'; | ||
import { isEntityItem } from '@irontec/ivoz-ui'; | ||
import DeleteRowButton from '@irontec/ivoz-ui/components/List/Content/CTA/DeleteRowButton'; | ||
import defaultEntityBehavior, { | ||
ChildDecorator as DefaultChildDecorator, | ||
} from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; | ||
import EntityInterface, { | ||
ChildDecoratorType, | ||
} from '@irontec/ivoz-ui/entities/EntityInterface'; | ||
import _ from '@irontec/ivoz-ui/services/translations/translate'; | ||
import AccountTreeIcon from '@mui/icons-material/AccountTree'; | ||
import MailIcon from '@mui/icons-material/Mail'; | ||
|
||
const VoiceMail: EntityInterface = { | ||
import { | ||
VoicemailProperties, | ||
VoicemailPropertyList, | ||
} from './VoicemailProperties'; | ||
|
||
const properties: VoicemailProperties = { | ||
enabled: { | ||
label: _('Enabled'), | ||
enum: { | ||
'0': _('No'), | ||
'1': _('Yes'), | ||
}, | ||
default: '1', | ||
}, | ||
name: { | ||
label: _('Name'), | ||
required: true, | ||
}, | ||
sendMail: { | ||
label: _('Voicemail send mail'), | ||
enum: { | ||
'0': _('No'), | ||
'1': _('Yes'), | ||
}, | ||
default: '1', | ||
visualToggle: { | ||
'0': { | ||
show: [], | ||
hide: ['attachSound', 'email'], | ||
}, | ||
'1': { | ||
show: ['attachSound', 'email'], | ||
hide: [], | ||
}, | ||
}, | ||
}, | ||
email: { | ||
label: _('Email'), | ||
required: true, | ||
}, | ||
attachSound: { | ||
label: _('Voicemail attach sound'), | ||
enum: { | ||
'0': _('No'), | ||
'1': _('Yes'), | ||
}, | ||
default: '1', | ||
}, | ||
}; | ||
|
||
const columns = ['enabled', 'name', 'email']; | ||
|
||
export const ChildDecorator: ChildDecoratorType = (props) => { | ||
const { routeMapItem, row, entityService } = props; | ||
|
||
if ( | ||
isEntityItem(routeMapItem) && | ||
routeMapItem.entity.iden === voicemail.iden | ||
) { | ||
const isDeletePath = routeMapItem.route === `${voicemail.path}/:id`; | ||
|
||
if (isDeletePath) { | ||
return ( | ||
<DeleteRowButton | ||
disabled={true} | ||
row={row} | ||
entityService={entityService} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
return DefaultChildDecorator(props); | ||
}; | ||
|
||
const voicemail: EntityInterface = { | ||
...defaultEntityBehavior, | ||
icon: AccountTreeIcon, | ||
icon: MailIcon, | ||
iden: 'Voicemail', | ||
title: _('Voicemail', { count: 2 }), | ||
path: '/my/company_voicemails', | ||
path: '/my/voicemails', | ||
|
||
acl: { | ||
...defaultEntityBehavior.acl, | ||
iden: 'Voicemail', | ||
iden: 'Voicemails', | ||
}, | ||
selectOptions: async () => { | ||
const module = await import('./SelectOptions'); | ||
toStr: (row: VoicemailPropertyList<string>) => `${row.name as string}`, | ||
properties, | ||
columns, | ||
defaultOrderBy: '', | ||
ChildDecorator, | ||
Form: async () => { | ||
const module = await import('./Form'); | ||
|
||
return module.default; | ||
}, | ||
toStr: (row: EntityValues) => row.name as string, | ||
}; | ||
|
||
export default VoiceMail; | ||
export default voicemail; |
21 changes: 21 additions & 0 deletions
21
web/portal/user/src/entities/Voicemail/VoicemailProperties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { PropertySpec } from '@irontec/ivoz-ui/services/api/ParsedApiSpecInterface'; | ||
import { | ||
EntityValue, | ||
EntityValues, | ||
} from '@irontec/ivoz-ui/services/entity/EntityService'; | ||
|
||
export type VoicemailPropertyList<T> = { | ||
id?: T; | ||
enabled?: T; | ||
user?: T; | ||
name?: T; | ||
email?: T; | ||
sendMail?: T; | ||
attachSound?: T; | ||
voicemail?: T; | ||
}; | ||
|
||
export type VoicemailProperties = VoicemailPropertyList<Partial<PropertySpec>>; | ||
export type VoicemailPropertiesList = Array< | ||
VoicemailPropertyList<EntityValue | EntityValues> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters