Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
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
ulakbus
ulakbus-ui
Commits
9a568d0b
Commit
9a568d0b
authored
Jul 27, 2016
by
Vladimir Baranov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rref #5385. Add directive for Classroom Timetabling
parent
b444025f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
77 deletions
+133
-77
crud_controller.js
app/components/crud/crud_controller.js
+102
-46
timetable.html
app/components/crud/templates/timetable.html
+31
-31
No files found.
app/components/crud/crud_controller.js
View file @
9a568d0b
...
...
@@ -484,13 +484,8 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
}
};
})
/**
* @memberof ulakbus.crud
* @ngdoc directive
* @name crudTimetableDirective
* @description directive for displaying timetable widget
*/
.
directive
(
"crudTimetableDirective"
,
function
(
WSOps
,
$q
){
.
controller
(
"crudTimetableDirectiveCtrl"
,
function
(
$scope
,
WSOps
,
$q
){
// todo: replace with utils service method
function
groupBy
(
list
,
propName
)
{
return
list
.
reduce
(
function
(
acc
,
item
)
{
...
...
@@ -498,71 +493,132 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
return
acc
;
},
{});
};
$scope
.
groupBy
=
groupBy
;
function
get_wf
(
scope
,
data
){
data
.
token
=
scope
.
token
;
data
.
wf
=
scope
.
wf
;
$scope
.
get_wf
=
function
get_wf
(
data
){
var
fieldName
=
$scope
.
mainFieldName
||
'ogretim_elemani_zt'
;
data
.
token
=
$scope
.
token
;
data
.
wf
=
$scope
.
wf
;
return
WSOps
.
request
(
data
).
then
(
function
(
result
){
if
(
result
.
ogretim_elemani_zt
){
if
(
result
[
fieldName
]
){
return
result
;
}
else
{
Generator
.
pathDecider
(
result
.
client_cmd
||
[
'list'
],
scope
,
result
);
}
Generator
.
pathDecider
(
result
.
client_cmd
||
[
'list'
],
$
scope
,
result
);
// prevent result processing
return
$q
.
reject
();
}
}).
then
(
function
(
result
){
scope
.
message
=
result
.
msgbox
;
return
result
.
ogretim_elemani_zt
$scope
.
message
=
result
.
notification
;
return
result
[
fieldName
]
})
}
$scope
.
prepareTimetable
=
function
prepareTimetable
(
timetable
){
var
grouped
=
groupBy
(
timetable
,
"saat"
);
for
(
var
day
in
grouped
){
var
dayItems
=
grouped
[
day
];
grouped
[
day
]
=
dayItems
.
sort
(
function
(
a
,
b
){
return
a
.
gun
<
b
.
gun
?
-
1
:
1
;
});
}
var
acc
=
[];
for
(
var
t
in
grouped
){
if
(
grouped
.
hasOwnProperty
(
t
)){
acc
.
push
([
t
,
grouped
[
t
]]);
}
}
return
acc
.
sort
(
function
(
a
,
b
){
return
a
[
0
]
>
b
[
0
]
?
1
:
-
1
;
});
}
})
.
directive
(
"crudTimetableDirective"
,
function
(){
return
{
templateUrl
:
'components/crud/templates/timetable.html'
,
restrict
:
'E'
,
replace
:
true
,
controller
:
'crudTimetableDirectiveCtrl'
,
link
:
function
(
iScope
,
iElem
,
iAtrrs
){
var
mainFieldName
=
'ogretim_elemani_zt'
;
iScope
.
mainFieldName
=
mainFieldName
;
iScope
.
tablesList
=
iScope
[
mainFieldName
].
ogretim_elemanlari
;
iScope
.
widgetTitle
=
"Öğretim Elemanı Zaman Tablosu"
iScope
.
lecturerList
=
iScope
.
ogretim_elemani_zt
.
ogretim_elemanlari
;
initLecturer
(
iScope
.
ogretim_elemani_zt
);
iScope
.
availableStates
=
[
{
value
:
1
,
name
:
"Uygun"
},
{
value
:
2
,
name
:
"Belirsiz"
},
{
value
:
3
,
name
:
"Meşgul"
}
];
initLecturer
(
iScope
[
mainFieldName
]);
function
initLecturer
(
data
){
iScope
.
current
Lecturer
=
{
iScope
.
current
Table
=
{
key
:
data
.
oe_key
,
name
:
data
.
name
,
avatar_url
:
data
.
avatar_url
,
totalHours
:
data
.
toplam_ders_saati
};
prepareTimetable
(
data
.
uygunluk_durumu
);
iScope
.
timetable
=
iScope
.
prepareTimetable
(
data
.
uygunluk_durumu
);
};
function
prepareTimetable
(
timetable
){
var
grouped
=
groupBy
(
timetable
,
"saat"
);
for
(
var
day
in
grouped
){
var
dayItems
=
grouped
[
day
];
grouped
[
day
]
=
dayItems
.
sort
(
function
(
a
,
b
){
return
a
.
gun
<
b
.
gun
?
-
1
:
1
;
});
iScope
.
selectTable
=
function
(
lecturer
){
iScope
.
loadingTable
=
true
;
iScope
.
get_wf
({
cmd
:
'personel_sec'
,
secili_og_elemani
:
{
key
:
lecturer
.
key
}
}).
then
(
function
(
response
){
initLecturer
(
response
);
}).
finally
(
function
(){
iScope
.
loadingTable
=
false
;
})
};
iScope
.
changeValue
=
function
(
time
){
iScope
.
loadingAction
=
true
;
iScope
.
get_wf
({
cmd
:
'degistir'
,
change
:
{
'key'
:
time
.
key
,
'durum'
:
time
.
durum
}
var
acc
=
[];
for
(
var
t
in
grouped
){
if
(
grouped
.
hasOwnProperty
(
t
)){
acc
.
push
([
t
,
grouped
[
t
]]);
}).
then
(
function
(
table
){
var
days
=
table
.
uygunluk_durumu
;
// update durum value from the response
for
(
var
i
=
0
;
i
<
days
.
length
;
i
++
){
if
(
days
[
i
].
key
==
time
.
key
){
time
.
durum
=
days
[
i
].
durum
;
break
;
}
}
iScope
.
timetable
=
acc
.
sort
(
function
(
a
,
b
){
return
a
[
0
]
>
b
[
0
]
?
1
:
-
1
;
})
;
}).
finally
(
function
(
){
iScope
.
loadingAction
=
false
;
})
}
}
}
})
.
directive
(
"crudTimetableDirective2"
,
function
(){
return
{
templateUrl
:
'components/crud/templates/timetable.html'
,
restrict
:
'E'
,
replace
:
true
,
controller
:
'crudTimetableDirectiveCtrl'
,
link
:
function
(
iScope
,
iElem
,
iAtrrs
){
var
mainFieldName
=
'derslik_zaman_tablosu'
;
iScope
.
mainFieldName
=
mainFieldName
;
iScope
.
tablesList
=
iScope
[
mainFieldName
].
derslikler
;
iScope
.
widgetTitle
=
"Derslik Zaman Tablosu"
;
initTable
(
iScope
[
mainFieldName
]);
function
initTable
(
data
){
iScope
.
currentTable
=
{
key
:
data
.
oe_key
,
name
:
data
.
name
,
avatar_url
:
data
.
avatar_url
};
iScope
.
timetable
=
iScope
.
prepareTimetable
(
data
.
zaman_plani
);
};
iScope
.
select
Lecturer
=
function
(
lecturer
){
iScope
.
select
Table
=
function
(
lecturer
){
iScope
.
loadingTable
=
true
;
get_wf
(
iScope
,
{
iScope
.
get_wf
(
{
cmd
:
'personel_sec'
,
secili_og_elemani
:
{
key
:
lecturer
.
key
}
}).
then
(
function
(
response
){
...
...
@@ -574,7 +630,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
iScope
.
changeValue
=
function
(
time
){
iScope
.
loadingAction
=
true
;
get_wf
(
iScope
,
{
iScope
.
get_wf
(
{
cmd
:
'degistir'
,
change
:
{
'key'
:
time
.
key
,
...
...
app/components/crud/templates/timetable.html
View file @
9a568d0b
...
...
@@ -2,13 +2,13 @@
<div
class=
"col-md-12 course-prg-scheduler"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"panel-title"
>
Course Scheduler Widget
</div>
<div
class=
"panel-title"
>
{{widgetTitle}}
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"col-xs-3"
>
<!-- required for floating -->
<div
class=
"col-xs-3
tabs-container
"
>
<!-- required for floating -->
<ul
class=
"tabs-left"
>
<li
ng-repeat=
"
lecturer in lecturerList"
ng-click=
"selectLecturer(lecturer)"
ng-class=
"{active: currentLecturer.key == lecturer.key}"
><a>
{{lecturer
.name}}
</a></li>
<li
ng-repeat=
"
table in tablesList"
ng-click=
"selectTable(table)"
ng-class=
"{active: currentTable.key == table.key}"
><a>
{{table
.name}}
</a></li>
</ul>
</div>
...
...
@@ -17,24 +17,23 @@
<!-- Tab panes -->
<div
class=
"tab-content"
ng-hide=
"loadingTable"
>
<div
class=
"tab-pane active"
id=
"one"
>
<div
class=
"tab-pane active"
>
<div
class=
"info-header clearfix"
>
<div
class=
"info-wrapper"
>
<img
ng-src=
"{{current
Lecturer.avatar_url}}"
class=
"profile-pic
"
>
<span
class=
"user-name"
>
{{current
Lecturer
.name}}
</span>
<img
ng-src=
"{{current
Table.avatar_url}}"
class=
"profile-pic"
ng-show=
"currentTable.avatar_url
"
>
<span
class=
"user-name"
>
{{current
Table
.name}}
</span>
</div>
<div
class=
"info-wrapper info-wrapper_hours"
>
<span
class=
"info-title"
>
Ders Yükü:
</span>
<span>
{{current
Lecturer
.totalHours}} saat
</span>
<div
class=
"info-wrapper info-wrapper_hours"
ng-show=
"currentTable.totalHours"
>
<span
class=
"info-title"
>
Ders Yükü:
</span>
<span>
{{current
Table
.totalHours}} saat
</span>
</div>
</div>
<!-- end of header -->
<div
class=
"table-warning"
ng-show=
"message"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
></span>
{{message.
title}}
<br/>
{{message.msg
}}
<span
class=
"glyphicon glyphicon-exclamation-sign"
></span>
{{message.
message
}}
</div>
<table
border=
"1"
>
<div
class=
"table-container"
>
<table
>
<tbody>
<tr
class=
"headers"
>
<td></td>
...
...
@@ -49,11 +48,12 @@
<tr
ng-repeat=
"time in timetable"
>
<td>
{{time[0]}}
</td>
<td
ng-repeat=
"day in time[1]"
>
<div
timetable-action-selector
ng-model=
"day.durum
"
ng-change=
"changeValue(day)"
></div>
<div
timetable-action-selector
ng-model=
"day.durum"
readonly=
"{{currentTable.readonly}}
"
ng-change=
"changeValue(day)"
></div>
</td>
</tr>
</tbody>
</table>
</div>
<div
class=
"loader pull-right"
ng-show=
"loadingAction"
>
Loading...
</div>
<ul
class=
"legend"
>
<li>
...
...
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