Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
686992d7
authored
Jul 27, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
depurating picto expression update
parent
34168770
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
42 deletions
sails/src/api/controllers/PictoController.js
sails/src/api/controllers/PictoController.js
View file @
686992d7
...
...
@@ -218,49 +218,37 @@ module.exports = {
change_exp
:
function
(
req
,
res
)
{
var
params
=
req
.
params
.
all
();
if
(
params
.
lang
&&
params
.
text
)
{
PictoExp
.
findOne
({
id
:
params
.
picto
,
lang
:
params
.
lang
}).
then
(
function
(
pictoExpression
)
{
if
(
!
pictoExpression
)
{
Picto
.
findOne
({
id
:
params
.
picto
}).
then
(
function
(
picto
)
{
if
(
!
picto
)
{
res
.
badRequest
();
throw
new
Error
(
'Picto not found'
);
}
PictoExp
.
create
({
lang
:
params
.
lang
,
text
:
params
.
text
,
picto
:
picto
.
id
}).
then
(
function
(
newPictoExpression
)
{
if
(
newPictoExpression
)
{
res
.
ok
(
newPictoExpression
);
}
else
{
res
.
serverError
();
}
})
.
catch
(
function
()
{
res
.
serverError
();
});
})
.
catch
(
function
()
{
res
.
serverError
();
});
}
else
{
pictoExpression
.
text
=
params
.
text
;
pictoExpression
.
save
(
function
(
error
)
{
if
(
error
)
{
res
.
serverError
();
}
else
{
res
.
ok
(
pictoExpression
);
}
if
(
!
params
.
lang
||
!
params
.
text
)
return
res
.
badRequest
();
PictoExp
.
findOne
({
id
:
params
.
picto
,
lang
:
params
.
lang
})
.
then
(
function
(
pictoExpression
)
{
if
(
!
pictoExpression
)
{
Picto
.
findOne
({
id
:
params
.
picto
}).
then
(
function
(
picto
)
{
if
(
!
picto
)
return
res
.
badRequest
(
'Error: Picto not found'
);
PictoExp
.
create
({
lang
:
params
.
lang
,
text
:
params
.
text
,
picto
:
picto
.
id
}).
then
(
function
(
newPictoExpression
)
{
if
(
!
newPictoExpression
)
throw
new
Error
(
"Could not create picto expression"
);
return
res
.
ok
(
newPictoExpression
);
});
}
})
.
catch
(
function
()
{
res
.
serverError
();
});
}
else
{
res
.
badRequest
();
}
});
}
else
{
pictoExpression
.
text
=
params
.
text
;
pictoExpression
.
save
(
function
(
error
)
{
if
(
error
)
throw
new
Error
(
"Could not save expression"
);
return
res
.
ok
(
pictoExpression
);
});
}
})
.
catch
(
function
(
err
)
{
return
res
.
serverError
(
"Error from server: "
+
err
);
});
},
/**
...
...
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