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
385ff3d0
authored
Apr 18, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working on scenes - collections controller
parent
7c9d9a5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
26 deletions
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
385ff3d0
...
@@ -48,6 +48,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -48,6 +48,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
freeCategoryPictos
=
null
;
$scope
.
freeCategoryPictos
=
null
;
$scope
.
loadingPictos
=
true
;
$scope
.
loadingPictos
=
true
;
$scope
.
viewingScene
=
null
;
$scope
.
viewingScene
=
null
;
$scope
.
scenesList
=
null
;
$scope
.
isCategory
=
function
(
studentPicto
)
{
$scope
.
isCategory
=
function
(
studentPicto
)
{
return
studentPicto
.
attributes
.
id_cat
===
null
&&
return
studentPicto
.
attributes
.
id_cat
===
null
&&
...
@@ -120,26 +121,61 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -120,26 +121,61 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
};
};
// Reload student pictos (back from addpicto)
// Reload student pictos (back from addpicto)
$scope
.
loadPictos
=
function
()
{
$scope
.
loadPictos
=
function
(
scene
)
{
// Fill with grid (if not done before)
// Fill with grid (if not done before)
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
scene
.
pictos
.
forEach
(
placePicto
);
$scope
.
loadingPictos
=
false
;
};
// get active scene
$scope
.
showActiveScene
=
function
(
scene
)
{
// Get user's pictos
$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
=
!
$scope
.
studentData
.
attributes
.
categories
;
$scope
.
showFreeCategory
=
!
activeScene
.
categories
;
$scope
.
viewingScene
=
activeScene
.
id
;
$scope
.
viewingScene
=
activeScene
;
activeScene
.
pictos
.
forEach
(
placePicto
);
$scope
.
loadPictos
(
activeScene
);
//studentPictos.forEach(placePicto);
//setTimeout(function () { $scope.$apply(); });
})
.
error
(
function
()
{
$translate
(
'error_loading_scene'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
});
};
$scope
.
loadingPictos
=
false
;
// get active scene
setTimeout
(
function
()
{
$scope
.
$apply
();
});
$scope
.
showScene
=
function
(
idScene
)
{
$http
.
get
(
config
.
backend
+
'/scene/'
+
idScene
)
.
success
(
function
(
scene
)
{
$scope
.
showFreeCategory
=
!
scene
.
categories
;
$scope
.
viewingScene
=
scene
;
$scope
.
loadPictos
(
scene
);
//setTimeout(function () { $scope.$apply(); });
})
.
error
(
function
()
{
$translate
(
'error_loading_scene'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
});
};
// get active scene
$scope
.
loadScenesList
=
function
()
{
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/scenes'
)
.
success
(
function
(
scenes
)
{
$scope
.
scenesList
=
scenes
;
//setTimeout(function () { $scope.$apply(); });
})
})
.
error
(
function
()
{
.
error
(
function
()
{
$translate
(
'error_loading_
picto
s'
).
then
(
function
(
translation
)
{
$translate
(
'error_loading_
scene
s'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
ngToast
.
danger
({
content
:
translation
});
});
});
});
});
...
@@ -169,6 +205,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -169,6 +205,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
action
:
'delete'
,
action
:
'delete'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
studentPicto
stu_picto
:
studentPicto
}
}
},
function
()
{});
},
function
()
{});
...
@@ -182,6 +219,58 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -182,6 +219,58 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
});
});
};
};
// Delete student picto
$scope
.
delete_scene
=
function
(
idScene
)
{
$translate
(
'confirmation'
).
then
(
t
=>
{
if
(
$window
.
confirm
(
t
))
{
$http
.
delete
(
config
.
backend
+
'/scene/'
+
idScene
)
.
success
(
function
()
{
// io.socket.post('/stu/vocabulary', {
// action: 'delete',
// attributes: {
// id_stu: $scope.studentData.id,
// id_scene: $scope.viewingScene.id,
// stu_picto: studentPicto
// }
// }, function () {});
//
// $translate('picto_removed').then(function (translation) {
// ngToast.success({ content: translation });
// });
}).
error
(
function
()
{});
}
});
};
// Delete student picto
$scope
.
update_scene
=
function
(
scene
)
{
$http
.
put
(
config
.
backend
+
'/scene/'
+
idScene
,
{
name
:
scene
.
name
,
active
:
scene
.
active
})
.
success
(
function
()
{
var
data
=
{
name
:
scene
.
name
,
active
:
scene
.
active
,
categories
:
scene
.
categories
,
student
:
scene
.
student
,
supervisor
:
scene
.
supervisor
};
io
.
socket
.
post
(
'/scene'
,
{
action
:
'update'
,
scene
:
data
},
function
()
{});
$translate
(
'scene_updated'
).
then
(
function
(
translation
)
{
ngToast
.
success
({
content
:
translation
});
});
}).
error
(
function
()
{});
};
$scope
.
deleteFreePicto
=
function
(
studentPicto
)
{
$scope
.
deleteFreePicto
=
function
(
studentPicto
)
{
$translate
(
'confirmation'
).
then
(
t
=>
{
$translate
(
'confirmation'
).
then
(
t
=>
{
if
(
$window
.
confirm
(
t
))
{
if
(
$window
.
confirm
(
t
))
{
...
@@ -195,6 +284,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -195,6 +284,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
action
:
'delete'
,
action
:
'delete'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
studentPicto
stu_picto
:
studentPicto
}
}
},
function
()
{});
},
function
()
{});
...
@@ -226,6 +316,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -226,6 +316,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
action
:
'update'
,
action
:
'update'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
newStuPicto
stu_picto
:
newStuPicto
}
}
},
function
()
{});
},
function
()
{});
...
@@ -288,6 +379,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -288,6 +379,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
action
:
'update'
,
action
:
'update'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
newStudentPicto
stu_picto
:
newStudentPicto
}
}
},
function
()
{
},
function
()
{
...
@@ -333,13 +425,14 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -333,13 +425,14 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
new_id_pic
:
pictoId
new_id_pic
:
pictoId
})
})
.
success
(
function
(
studentPicto
)
{
.
success
(
function
(
studentPicto
)
{
$scope
.
loadPictos
();
$scope
.
loadPictos
(
$scope
.
viewingScene
);
// notify
// notify
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
action
:
'update_category'
,
action
:
'update_category'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
studentPicto
stu_picto
:
studentPicto
}
}
},
function
()
{});
},
function
()
{});
...
@@ -388,7 +481,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -388,7 +481,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
free_category_coord_x
:
$scope
.
showFreeCategory
?
col
:
null
,
free_category_coord_x
:
$scope
.
showFreeCategory
?
col
:
null
,
free_category_coord_y
:
$scope
.
showFreeCategory
?
row
:
null
free_category_coord_y
:
$scope
.
showFreeCategory
?
row
:
null
},
},
id_scene
:
$scope
.
viewingScene
id_scene
:
$scope
.
viewingScene
.
id
})
})
.
success
(
function
(
studentPicto
)
{
.
success
(
function
(
studentPicto
)
{
placePicto
(
studentPicto
);
placePicto
(
studentPicto
);
...
@@ -397,6 +490,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -397,6 +490,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
action
:
'add'
,
action
:
'add'
,
attributes
:
{
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
studentPicto
stu_picto
:
studentPicto
}
}
},
function
()
{});
},
function
()
{});
...
@@ -462,23 +556,31 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -462,23 +556,31 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Add new listener to the event
// Add new listener to the event
io
.
socket
.
off
(
'vocabulary'
);
io
.
socket
.
off
(
'vocabulary'
);
io
.
socket
.
on
(
'vocabulary'
,
function
(
data
)
{
io
.
socket
.
on
(
'vocabulary'
,
function
(
data
)
{
switch
(
data
.
action
)
{
// switch (data.action) {
case
'add'
:
// case 'add':
$scope
.
loadPictos
();
// $scope.loadPictos();
break
;
// break;
case
'update'
:
// case 'update':
$scope
.
loadPictos
();
// $scope.loadPictos();
break
;
// break;
case
'delete'
:
// case 'delete':
$scope
.
loadPictos
();
// $scope.loadPictos();
break
;
// break;
default
:
// default:
$scope
.
loadPictos
();
// $scope.loadPictos();
break
;
// break;
// }
if
(
data
.
attributes
.
id_scene
==
$scope
.
viewingScene
.
id
){
//Reload scene
$translate
(
'reload_scene'
).
then
(
function
(
translation
)
{
ngToast
.
success
({
content
:
translation
});
});
$scope
.
showScene
(
data
.
attributes
.
id_scene
);
}
}
$scope
.
$apply
();
$scope
.
$apply
();
});
});
// Load pictos
// Load pictos
$scope
.
loadPictos
();
$scope
.
showActiveScene
();
$scope
.
loadScenesList
();
});
});
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