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
2a7a0ad9
authored
Apr 19, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working - Delete scene
parent
7910eae4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
41 deletions
sails/src/api/models/Scene.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/config/policies.js
sails/src/api/models/Scene.js
View file @
2a7a0ad9
...
@@ -56,7 +56,6 @@ module.exports = {
...
@@ -56,7 +56,6 @@ module.exports = {
pictos
:
function
(
id_scene
,
callback
)
{
pictos
:
function
(
id_scene
,
callback
)
{
var
l
=
[];
var
l
=
[];
var
fs
=
require
(
'fs'
);
var
fs
=
require
(
'fs'
);
console
.
log
(
"metodo pictos scene"
);
Scene
.
findOne
(
id_scene
)
Scene
.
findOne
(
id_scene
)
.
then
((
scene
)
=>
{
.
then
((
scene
)
=>
{
if
(
!
scene
)
if
(
!
scene
)
...
...
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
2a7a0ad9
...
@@ -120,26 +120,18 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -120,26 +120,18 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}
}
};
};
// Reload student pictos (back from addpicto)
$scope
.
loadPictos
=
function
(
scene
)
{
// Fill with grid (if not done before)
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
scene
.
pictos
.
forEach
(
placePicto
);
$scope
.
loadingPictos
=
false
;
};
// get active scene
// get active scene
$scope
.
showActiveScene
=
function
(
scene
)
{
$scope
.
showActiveScene
=
function
(
scene
)
{
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/activeScene'
)
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/activeScene'
)
.
success
(
function
(
activeScene
)
{
.
success
(
function
(
activeScene
)
{
$scope
.
showFreeCategory
=
!
activeScene
.
categories
;
$scope
.
showFreeCategory
=
!
activeScene
.
categories
;
$scope
.
viewingScene
=
activeScene
;
$scope
.
viewingScene
=
activeScene
;
$scope
.
loadPictos
(
activeScene
);
activeScene
.
pictos
.
forEach
(
placePicto
);
$scope
.
loadingPictos
=
false
;
//setTimeout(function () { $scope.$apply(); });
//setTimeout(function () { $scope.$apply(); });
})
})
.
error
(
function
()
{
.
error
(
function
()
{
...
@@ -152,11 +144,16 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -152,11 +144,16 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// get active scene
// get active scene
$scope
.
showScene
=
function
(
idScene
)
{
$scope
.
showScene
=
function
(
idScene
)
{
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
$http
.
get
(
config
.
backend
+
'/scene/'
+
idScene
)
$http
.
get
(
config
.
backend
+
'/scene/'
+
idScene
)
.
success
(
function
(
scene
)
{
.
success
(
function
(
scene
)
{
$scope
.
showFreeCategory
=
!
scene
.
categories
;
$scope
.
showFreeCategory
=
!
scene
.
categories
;
$scope
.
viewingScene
=
scene
;
$scope
.
viewingScene
=
scene
;
$scope
.
loadPictos
(
scene
);
scene
.
pictos
.
forEach
(
placePicto
);
$scope
.
loadingPictos
=
false
;
//setTimeout(function () { $scope.$apply(); });
//setTimeout(function () { $scope.$apply(); });
})
})
.
error
(
function
()
{
.
error
(
function
()
{
...
@@ -219,28 +216,43 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -219,28 +216,43 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
});
});
};
};
// Delete student picto
// Delete student scene, if is not active
//If scene is viewingScene, load activeScene
$scope
.
delete_scene
=
function
(
idScene
)
{
$scope
.
delete_scene
=
function
(
idScene
)
{
var
active
=
false
;
var
viewing
=
idScene
==
$scope
.
viewingScene
.
id
;
for
(
var
i
=
0
;
i
<
$scope
.
scenesList
;
i
++
){
if
(
$scope
.
scenesList
[
i
].
id
==
idScene
){
active
=
$scope
.
scenesList
[
i
].
active
;
}
}
$translate
(
'confirmation'
).
then
(
t
=>
{
$translate
(
'confirmation'
).
then
(
t
=>
{
if
(
$window
.
confirm
(
t
))
{
if
(
$window
.
confirm
(
t
))
{
$http
.
delete
(
config
.
backend
+
'/scene/'
+
idScene
)
if
(
!
active
){
.
success
(
function
()
{
$http
.
delete
(
config
.
backend
+
'/scene/'
+
idScene
)
.
success
(
function
()
{
io
.
socket
.
post
(
'/scene'
,
{
// io.socket.post('/stu/vocabulary', {
action
:
'delete'
,
// action: 'delete',
data
:
{
id
:
idScene
}
// attributes: {
},
function
()
{});
// id_stu: $scope.studentData.id,
if
(
viewing
){
// id_scene: $scope.viewingScene.id,
$scope
.
showActiveScene
();
// stu_picto: studentPicto
}
// }
$scope
.
loadScenesList
();
// }, function () {});
$translate
(
'scene_deleted'
).
then
(
function
(
translation
)
{
//
ngToast
.
success
({
content
:
translation
});
// $translate('picto_removed').then(function (translation) {
});
// ngToast.success({ content: translation });
// });
}).
error
(
function
()
{
$translate
(
'scene_already_deleted'
).
then
(
function
(
translation
)
{
}).
error
(
function
()
{});
ngToast
.
warning
({
content
:
translation
});
});
});
}
else
{
$translate
(
'cant_delete_active_scene'
).
then
(
function
(
translation
)
{
ngToast
.
warning
({
content
:
translation
});
});
}
}
}
});
});
};
};
...
@@ -248,7 +260,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -248,7 +260,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Delete student picto
// Delete student picto
$scope
.
update_scene
=
function
(
scene
)
{
$scope
.
update_scene
=
function
(
scene
)
{
$http
.
put
(
config
.
backend
+
'/scene/'
+
idScene
,
{
$http
.
put
(
config
.
backend
+
'/scene/'
+
scene
.
id
,
{
name
:
scene
.
name
,
name
:
scene
.
name
,
active
:
scene
.
active
})
active
:
scene
.
active
})
.
success
(
function
()
{
.
success
(
function
()
{
...
@@ -425,7 +437,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -425,7 +437,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
new_id_pic
:
pictoId
new_id_pic
:
pictoId
})
})
.
success
(
function
(
studentPicto
)
{
.
success
(
function
(
studentPicto
)
{
$scope
.
loadPictos
(
$scope
.
viewingScene
);
$scope
.
showScene
(
$scope
.
viewingScene
.
id
);
// notify
// notify
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
...
@@ -502,9 +514,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -502,9 +514,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
else
else
ngToast
.
danger
({
content
:
$translate
.
instant
(
'error_adding_picto'
)
});
ngToast
.
danger
({
content
:
$translate
.
instant
(
'error_adding_picto'
)
});
});
});
// not needed
// $scope.loadPictos();
});
});
};
};
...
...
sails/src/config/policies.js
View file @
2a7a0ad9
...
@@ -85,7 +85,8 @@ module.exports.policies = {
...
@@ -85,7 +85,8 @@ module.exports.policies = {
update
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
update
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
destroy
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
destroy
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
getScene
:
[
'tokenAuth'
],
getScene
:
[
'tokenAuth'
],
getStudentScenes
:
[
'tokenAuth'
]
getStudentScenes
:
[
'tokenAuth'
],
scene
:
true
},
},
ServerController
:
{
ServerController
:
{
...
@@ -124,7 +125,8 @@ module.exports.policies = {
...
@@ -124,7 +125,8 @@ module.exports.policies = {
delete
:
[
'tokenAuth'
,
'isSupAdmin'
],
delete
:
[
'tokenAuth'
,
'isSupAdmin'
],
unlink_supervisor
:
[
'tokenAuth'
,
'isSupAdmin'
],
unlink_supervisor
:
[
'tokenAuth'
,
'isSupAdmin'
],
delete_picto
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
delete_picto
:
[
'tokenAuth'
,
'isSupervisorOfStudent'
],
getActiveScene
:
[
'tokenAuth'
]
getActiveScene
:
[
'tokenAuth'
],
getScenes
:
[
'tokenAuth'
]
},
},
LicenseController
:
{
LicenseController
:
{
...
...
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