Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
06606994
Commit
06606994
authored
Apr 30, 2016
by
Elias Nahum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Domain edit with the ability to move between companies
parent
b6f96f9d
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
352 additions
and
171 deletions
+352
-171
create_domain.jsx
src/components/domain/create_domain.jsx
+10
-9
edit_domain.jsx
src/components/domain/edit_domain.jsx
+273
-134
company_store.jsx
src/stores/company_store.jsx
+49
-27
client.jsx
src/utils/client.jsx
+19
-0
utils.jsx
src/utils/utils.jsx
+1
-1
No files found.
src/components/domain/create_domain.jsx
View file @
06606994
...
...
@@ -69,12 +69,16 @@ export default class CreateDomain extends React.Component {
handleSubmit
(
e
)
{
e
.
preventDefault
();
GlobalActions
.
emitStartLoading
();
const
elementList
=
document
.
querySelectorAll
(
'.has-error'
);
Array
.
from
(
elementList
).
forEach
((
el
)
=>
el
.
classList
.
remove
(
'has-error'
));
Utils
.
validateInputRequired
(
this
.
refs
).
then
(()
=>
{
const
plans
=
Object
.
keys
(
this
.
state
.
plans
);
const
zimbraDomainCOSMaxAccounts
=
[];
const
name
=
this
.
refs
.
domainName
.
value
.
trim
();
const
businessCategory
=
this
.
refs
.
account
.
value
.
trim
();
const
businessCategory
=
this
.
refs
.
company
.
value
.
trim
();
plans
.
forEach
((
p
)
=>
{
zimbraDomainCOSMaxAccounts
.
push
(
`
${
this
.
refs
[
`plan-
${
p
}
`
].
getAttribute
(
'data-id'
)}
:
${
this
.
refs
[
`plan-
${
p
}
`
].
value
||
0
}
`
);
...
...
@@ -105,6 +109,7 @@ export default class CreateDomain extends React.Component {
GlobalActions
.
emitEndLoading
();
error
.
refs
=
true
;
error
.
type
=
error
.
typeError
;
error
.
node
.
closest
(
'.form-group'
).
classList
.
add
(
'has-error'
);
return
this
.
setState
({
error
});
});
}
...
...
@@ -124,11 +129,7 @@ export default class CreateDomain extends React.Component {
}
let
errorBar
;
let
formClass
=
'simple_form form-horizontal mailbox-form'
;
if
(
error
)
{
if
(
error
.
refs
)
{
formClass
+=
' has-error'
;
}
errorBar
=
(
<
MessageBar
message=
{
error
.
message
}
...
...
@@ -187,7 +188,7 @@ export default class CreateDomain extends React.Component {
const
form
=
(
<
form
className=
{
formClass
}
className=
'simple_form form-horizontal mailbox-form'
onSubmit=
{
this
.
handleSubmit
}
>
<
div
className=
'form-group string required'
>
...
...
@@ -211,15 +212,15 @@ export default class CreateDomain extends React.Component {
<
div
className=
'form-group string'
>
<
label
className=
'string required col-sm-3 control-label'
>
<
abbr
title=
'requerido'
>
{
'*'
}
</
abbr
>
{
'
Cuent
a'
}
{
'
Empres
a'
}
</
label
>
<
div
className=
'col-sm-8'
>
<
select
className=
'form-control select required'
data
-
required=
'true'
data
-
message=
'Debe especificar a que
cuent
a corresponde el dominio'
ref=
'
account
'
data
-
message=
'Debe especificar a que
empres
a corresponde el dominio'
ref=
'
company
'
defaultValue=
{
this
.
state
.
companyId
}
>
{
companiesOptions
}
...
...
src/components/domain/edit_domain.jsx
View file @
06606994
This diff is collapsed.
Click to expand it.
src/stores/company_store.jsx
View file @
06606994
...
...
@@ -67,49 +67,71 @@ class CompanyStoreClass {
}
}
addDomainAdmins
(
companyId
,
domain
)
{
function
findDomain
(
company
)
{
const
domains
=
company
.
domains
;
let
index
=
-
1
;
modifyDomain
(
prevCompanyId
,
domain
)
{
if
(
this
.
companies
)
{
const
domainCompanyId
=
domain
.
attrs
.
businessCategory
;
const
prevCompany
=
this
.
companies
[
prevCompanyId
];
const
newCompany
=
this
.
companies
[
domainCompanyId
];
if
(
domains
)
{
domains
.
forEach
((
d
,
i
)
=>
{
if
(
d
.
id
===
domain
.
id
)
{
index
=
i
;
return
false
;
}
return
true
;
});
if
(
prevCompanyId
!==
domainCompanyId
)
{
if
(
newCompany
)
{
this
.
addDomain
(
newCompany
.
id
,
domain
);
}
return
index
;
if
(
prevCompany
)
{
const
index
=
findDomain
(
prevCompany
,
domain
);
prevCompany
.
domains
.
splice
(
index
,
1
);
}
}
else
if
(
prevCompany
)
{
const
index
=
findDomain
(
prevCompany
,
domain
);
replaceDomain
(
prevCompany
,
domain
,
index
);
}
function
replaceDomain
(
company
,
index
)
{
if
(
index
>=
0
)
{
company
.
domains
[
index
]
=
domain
;
}
else
{
company
.
domains
.
push
(
domain
);
}
}
addDomainAdmins
(
companyId
,
domain
)
{
const
currentCompany
=
this
.
getCurrent
();
const
company
=
this
.
getCompanyById
(
companyId
);
let
index
=
-
1
;
if
(
currentCompany
&&
currentCompany
.
id
===
companyId
)
{
index
=
findDomain
(
currentCompany
);
index
=
findDomain
(
currentCompany
,
domain
);
replaceDomain
(
currentCompany
,
index
);
replaceDomain
(
currentCompany
,
domain
,
index
);
if
(
company
)
{
this
.
companies
[
companyId
]
=
currentCompany
;
}
}
else
if
(
company
)
{
index
=
findDomain
(
company
);
index
=
findDomain
(
company
,
domain
);
replaceDomain
(
company
,
domain
,
index
);
}
}
}
function
findDomain
(
company
,
domain
)
{
const
domains
=
company
.
domains
;
let
index
=
-
1
;
replaceDomain
(
company
,
index
);
if
(
domains
)
{
domains
.
forEach
((
d
,
i
)
=>
{
if
(
d
.
id
===
domain
.
id
)
{
index
=
i
;
return
false
;
}
return
true
;
});
}
return
index
;
}
function
replaceDomain
(
company
,
domain
,
index
)
{
if
(
index
>=
0
)
{
company
.
domains
[
index
]
=
domain
;
}
else
{
company
.
domains
.
push
(
domain
);
}
}
...
...
src/utils/client.jsx
View file @
06606994
...
...
@@ -247,6 +247,25 @@ export function createDomain(domain, success, error) {
);
}
export
function
modifyDomain
(
domain
,
success
,
error
)
{
initZimbra
().
then
(
(
zimbra
)
=>
{
zimbra
.
modifyDomain
(
domain
.
id
,
domain
.
attrs
,
(
err
,
data
)
=>
{
if
(
err
)
{
const
e
=
handleError
(
'modifyDomain'
,
err
);
return
error
(
e
);
}
return
success
(
data
);
});
},
(
err
)
=>
{
const
e
=
handleError
(
'modifyDomain'
,
err
);
return
error
(
e
);
}
);
}
export
function
addDistributionList
(
name
,
attrs
,
success
,
error
)
{
initZimbra
().
then
(
(
zimbra
)
=>
{
...
...
src/utils/utils.jsx
View file @
06606994
...
...
@@ -170,7 +170,7 @@ export function validateInputRequired(refs) {
}
for
(
const
ref
in
refs
)
{
if
(
refs
.
hasOwnProperty
(
ref
))
{
if
(
refs
.
hasOwnProperty
(
ref
)
&&
refs
[
ref
].
hasAttribute
)
{
if
(
refs
[
ref
].
hasAttribute
(
'data-required'
)
&&
refs
[
ref
].
getAttribute
(
'data-required'
)
===
'true'
&&
refs
[
ref
].
value
===
''
)
{
let
message
;
if
(
refs
[
ref
].
getAttribute
(
'data-message'
)
&&
refs
[
ref
].
getAttribute
(
'data-message'
).
length
>
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment