rbbt-rest 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/rest/common/misc.rb +10 -0
- data/lib/rbbt/rest/workflow/jobs.rb +8 -7
- data/share/views/compass/app.sass +278 -3
- data/share/views/compass/base/color.sass +66 -0
- data/share/views/compass/blocks.sass +0 -0
- data/share/views/compass/mixins/_blocks.sass +76 -80
- data/share/views/compass/mixins/_compass.sass +0 -0
- data/share/views/compass/mixins/_hide.sass +76 -1
- data/share/views/compass/table.sass +142 -0
- data/share/views/compass/variables/colors.sass +7 -0
- data/share/views/compass/variables/sizes.sass +5 -0
- data/share/views/entity_partials/action_card.haml +5 -5
- data/share/views/entity_partials/action_controller.haml +31 -33
- data/share/views/entity_partials/entity_card.haml +28 -27
- data/share/views/entity_partials/entity_list_card.haml +30 -42
- data/share/views/entity_partials/entity_map_card.haml +35 -43
- data/share/views/entity_partials/list_container.haml +6 -6
- data/share/views/layout.haml +53 -59
- data/share/views/layout/coda.haml +1 -0
- data/share/views/layout/doctype.haml +8 -0
- data/share/views/layout/footer.haml +36 -10
- data/share/views/layout/header.haml +47 -0
- data/share/views/layout/top_menu.haml +27 -13
- data/share/views/partials/form.haml +4 -4
- data/share/views/partials/table.haml +2 -1
- data/share/views/partials/table/column.haml +8 -9
- data/share/views/partials/table/files.haml +2 -2
- data/share/views/partials/table/filters.haml +16 -16
- data/share/views/partials/table/page.haml +9 -15
- data/share/views/public/js/ng-favourites.js +13 -0
- data/share/views/public/js/rbbt.aesthetics.js +51 -0
- data/share/views/public/js/rbbt.entity.js +62 -0
- data/share/views/public/js/rbbt.entity_list.js +54 -0
- data/share/views/public/js/rbbt.entity_map.js +52 -0
- data/share/views/public/js/rbbt.favourites.js +286 -0
- data/share/views/public/js/rbbt.favourites.js.old +195 -0
- data/share/views/public/js/rbbt.js +40 -0
- data/share/views/public/js/rbbt.knowledge_base.js +24 -0
- data/share/views/public/js/rbbt.page.js +32 -0
- data/share/views/public/js/rbbt/actions.js +15 -14
- data/share/views/public/js/rbbt/table.js +6 -4
- data/share/views/tools/cytoscape.haml +310 -0
- data/share/views/tools/protein_tool.haml +383 -0
- data/share/views/tools/protein_tool/controls.haml +315 -0
- metadata +23 -2
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
- footer = table_options[:footer] unless defined? footer and footer
|
17
17
|
- footer = true if footer.nil?
|
18
|
+
- footer = false unless table_url
|
18
19
|
|
19
20
|
- page = @page unless defined? page and not page.nil?
|
20
21
|
|
@@ -61,7 +62,7 @@
|
|
61
62
|
= partial_render('partials/table/page', :page => page, :total_size => total_size)
|
62
63
|
|
63
64
|
- if table_url
|
64
|
-
|
65
|
+
.table_actions.ui.buttons
|
65
66
|
|
66
67
|
= partial_render('partials/table/filters', :table_url => table_url, :header => header, :id => "rbbt_reveal_" << Misc.digest(table_url))
|
67
68
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
- table_columns_id = "rbbt_table_columns_" << (rand * 1000).to_i.to_s
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
%
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
%a.save_column_list(href="#") save list
|
2
|
+
= reveal :column, table_columns_id, :class => 'ui compact button table_column' do
|
3
|
+
%ul.table_column_selector.clean_list
|
4
|
+
- header.each do |field|
|
5
|
+
%li.ui.basic.segment
|
6
|
+
%span.field= field
|
7
|
+
%a.save_column_map.ui.compact.button(href="#") save map
|
8
|
+
- if Entity.formats.include? field and Entity.formats[field].include? Entity::REST
|
9
|
+
%a.save_column_list.ui.compact.button(href="#") save list
|
@@ -1,20 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
-#.filter.ui.wrap.button
|
2
|
+
= reveal :filter, id, :class => 'ui compact button filter' do
|
3
|
+
- if @filter
|
4
|
+
- filter_values = Hash[*@filter.split(";;").collect{|f| f.split("~")}.flatten]
|
5
|
+
- else
|
6
|
+
- filter_values = {}
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
.filters()
|
9
|
+
= action_parameters nil, :class => 'filter_controls' do
|
10
|
+
- header.each do |field|
|
11
|
+
- input field, :string, "Filter for #{ field }", filter_values[field]
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
:markdown
|
14
|
+
Filters can be specified in several ways:
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
- *String of text*: perfect match (e.g. `Cancer`)
|
17
|
+
- *Regular expression*: flexible match (e.g. `/(bladder|breast)\s+cancer/i`)
|
18
|
+
- *Numeric comparison*: lower of grater than (e.g. `< 0.1` or `>= 2`)
|
19
|
+
- *Names: for entities* with names, such as genes or pathways; regular expression accepted (e.g. `:name:SF3B1` or `:name:/CDK\d/`)
|
20
20
|
|
@@ -4,35 +4,29 @@
|
|
4
4
|
- total_nums += 1 if total_size.to_i % size.to_i > 0
|
5
5
|
- start = [1, num - 2].max
|
6
6
|
- eend = [total_nums, num + 2].min
|
7
|
-
|
8
|
-
%
|
9
|
-
%a.prev(href="#") «
|
7
|
+
.table_pagination.pagination.ui.buttons
|
8
|
+
%a.ui.compact.arrow.button.prev(href="#") «
|
10
9
|
|
11
|
-
%
|
12
|
-
%a.next(href="#") »
|
10
|
+
%a.ui.compact.arrow.button.next(href="#") »
|
13
11
|
|
14
|
-
%
|
15
|
-
%a.all(href="#") all
|
12
|
+
%a.ui.compact.all.button.all(href="#") all
|
16
13
|
|
17
14
|
- if num - 2 > 1
|
18
|
-
%
|
19
|
-
%a(href="#") 1
|
15
|
+
%a.ui.compact.num.button(href="#") 1
|
20
16
|
|
21
17
|
- if num - 2 > 2
|
22
|
-
|
18
|
+
.ui.compact.disabled.button
|
23
19
|
\...
|
24
20
|
|
25
21
|
- (start..eend).each do |p|
|
26
|
-
%
|
27
|
-
%a(href="#")= p
|
22
|
+
%a.ui.compact.num.button(class="#{p.to_s == num.to_s ? "active" : "" }" href="#")= p
|
28
23
|
|
29
24
|
- if num + 3 < total_nums
|
30
|
-
|
25
|
+
.ui.compact.disabled.button
|
31
26
|
\...
|
32
27
|
|
33
28
|
- if num + 2 < total_nums
|
34
|
-
%
|
35
|
-
%a(href="#")= total_nums
|
29
|
+
%a.ui.compact.num.button(href="#")= total_nums
|
36
30
|
|
37
31
|
|
38
32
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
var rbbt_angular = angular.module('rbbt', [])
|
2
|
+
|
3
|
+
rbbt_angular.controller('FavourtiesController', ['$scope', function($scope){
|
4
|
+
$scope.favourite = 'not_favourite';
|
5
|
+
$scope.toggle = function(){
|
6
|
+
if ($scope.favourite == 'favourite'){
|
7
|
+
$scope.favourite = 'not_favourite'
|
8
|
+
}else{
|
9
|
+
$scope.favourite = 'favourite'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}]);
|
13
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
rbbt.aesthetics = {LS_key: "rbbt.aesthetics"}
|
2
|
+
|
3
|
+
var aes_module = rbbt.aesthetics
|
4
|
+
|
5
|
+
aes_module.load = function(){
|
6
|
+
this.aesthetics = rbbt.LS.load(this.LS_key)
|
7
|
+
if (undefined === this.aesthetics)
|
8
|
+
this.aesthetics = []
|
9
|
+
}
|
10
|
+
|
11
|
+
aes_module.store = function(){
|
12
|
+
rbbt.LS.store(this.LS_key, this.aesthetics)
|
13
|
+
}
|
14
|
+
|
15
|
+
aes_module.add = function(selector, aes, value){
|
16
|
+
this.aesthetics.push({selector: selector, aes: aes, value: value})
|
17
|
+
}
|
18
|
+
|
19
|
+
aes_module.clear_aesthetic = function(aes){
|
20
|
+
var data_key = 'data-aes-' + aesthetic.aes
|
21
|
+
|
22
|
+
$('[' + data_key + ']').attr(data_key, 'none')
|
23
|
+
}
|
24
|
+
|
25
|
+
aes_module.apply_aesthetic = function(aesthetic){
|
26
|
+
|
27
|
+
if (typeof aesthetic.selector == "string"){
|
28
|
+
targets = $(aesthetic.selector)
|
29
|
+
}else{
|
30
|
+
var items = aesthetic.selector
|
31
|
+
targets = $('.entity').filter(function(index){
|
32
|
+
var id = $(this).attr('data-entity-id')
|
33
|
+
return items.indexOf(id) >= 0
|
34
|
+
})
|
35
|
+
}
|
36
|
+
|
37
|
+
var data_key = 'data-aes-' + aesthetic.aes
|
38
|
+
targets.attr(data_key, aesthetic.value)
|
39
|
+
}
|
40
|
+
|
41
|
+
aes_module.apply = function(aesthetic){
|
42
|
+
if (undefined === aesthetic)
|
43
|
+
this.aesthetics.map(aes_module.apply_aesthetic)
|
44
|
+
else
|
45
|
+
aes_module.apply_aesthetic(aesthetic)
|
46
|
+
}
|
47
|
+
|
48
|
+
aes_module.load()
|
49
|
+
//aes_module.add(Object.keys(fav_module.entities.types()["Gene"]), 'color', 'red')
|
50
|
+
//aes_module.store()
|
51
|
+
//aes_module.apply()
|
@@ -0,0 +1,62 @@
|
|
1
|
+
rbbt.entity = {}
|
2
|
+
|
3
|
+
var Entity = function(data){
|
4
|
+
this.id = data.id
|
5
|
+
this.code = data.code
|
6
|
+
|
7
|
+
if (data.name !== undefined)
|
8
|
+
this.name = data.name
|
9
|
+
else
|
10
|
+
this.name = data.code
|
11
|
+
|
12
|
+
this.type = data.type
|
13
|
+
this.format = data.format
|
14
|
+
this.info = data.info
|
15
|
+
if (this.format === undefined && this.info !== undefined) this.format = this.info['format']
|
16
|
+
|
17
|
+
this.full_type = function(){
|
18
|
+
var full_type
|
19
|
+
if (this.format){ full_type = this.type + ":" + this.format }
|
20
|
+
else { full_type = this.type }
|
21
|
+
return full_type
|
22
|
+
}
|
23
|
+
|
24
|
+
this.link_info = function(){
|
25
|
+
var link_info = this.info
|
26
|
+
delete link_info['format']
|
27
|
+
return link_info
|
28
|
+
}
|
29
|
+
|
30
|
+
this.url = function(){
|
31
|
+
var url = "/entity/" + this.full_type() + "/" + this.code
|
32
|
+
url = add_parameters(url, this.link_info())
|
33
|
+
return url
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
var FavouriteEntities = function(by_type){
|
38
|
+
for (type in by_type){
|
39
|
+
this[type] = by_type[type]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
FavouriteEntities.deserialize = function(data){
|
44
|
+
data = JSON.parse(data)
|
45
|
+
favourite_entities = {}
|
46
|
+
for (type in data){
|
47
|
+
var type_data = data[type]
|
48
|
+
favourite_entities[type] = {}
|
49
|
+
for (code in type_data){
|
50
|
+
var info = type_data[code]
|
51
|
+
info.code = code
|
52
|
+
info.type = type
|
53
|
+
favourite_entities[type][code] = new Entity(info)
|
54
|
+
}
|
55
|
+
}
|
56
|
+
return favourite_entities
|
57
|
+
}
|
58
|
+
|
59
|
+
FavouriteEntities.get = function(){
|
60
|
+
return m.request({method: 'GET', url: '/favourite_entities', type: FavouriteEntities, deserialize: FavouriteEntities.deserialize})
|
61
|
+
}
|
62
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
var EntityList = function(data){
|
3
|
+
this.id = data.id
|
4
|
+
this.name = data.id
|
5
|
+
this.type = data.type
|
6
|
+
|
7
|
+
this.full_type = function(){
|
8
|
+
return this.type
|
9
|
+
}
|
10
|
+
|
11
|
+
this.url = function(){
|
12
|
+
var url = "/entity_list/" + this.full_type() + "/" + this.id
|
13
|
+
return url
|
14
|
+
}
|
15
|
+
|
16
|
+
this.get = function(){
|
17
|
+
var url = this.url()
|
18
|
+
url = add_parameter(url, '_format', 'json')
|
19
|
+
return m.request({url: url, method: 'GET'})
|
20
|
+
}
|
21
|
+
|
22
|
+
this.highlight = function(color){
|
23
|
+
this.get().then(function(list){
|
24
|
+
rbbt.aesthetics.apply_aesthetic({selector: list.entities, aes: 'color', value: color})
|
25
|
+
})
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
var FavouriteLists = function(by_type){
|
30
|
+
for (type in by_type){
|
31
|
+
this[type] = by_type[type]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
FavouriteLists.get = function(){
|
36
|
+
return m.request({method: 'GET', url: '/favourite_entity_lists', type: FavouriteLists, deserialize: FavouriteLists.deserialize})
|
37
|
+
}
|
38
|
+
|
39
|
+
FavouriteLists.deserialize = function(data){
|
40
|
+
data = JSON.parse(data)
|
41
|
+
favourite_lists = {}
|
42
|
+
for (type in data){
|
43
|
+
var type_data = data[type]
|
44
|
+
favourite_lists[type] = {}
|
45
|
+
for (i in type_data){
|
46
|
+
var info = {}
|
47
|
+
id = type_data[i]
|
48
|
+
info.id = id
|
49
|
+
info.type = type
|
50
|
+
favourite_lists[type][id] = new EntityList(info)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return favourite_lists
|
54
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
var EntityMap = function(data){
|
2
|
+
this.id = data.id
|
3
|
+
this.name = data.id
|
4
|
+
this.type = data.type
|
5
|
+
this.column = data.column
|
6
|
+
|
7
|
+
this.full_type = function(){
|
8
|
+
return this.type
|
9
|
+
}
|
10
|
+
|
11
|
+
this.url = function(){
|
12
|
+
var url = "/entity_map/" + this.full_type() + "/" + this.column + "/" + this.id
|
13
|
+
return url
|
14
|
+
}
|
15
|
+
|
16
|
+
this.get = function(){
|
17
|
+
var url = this.url()
|
18
|
+
url = add_parameter(url, '_format', 'json')
|
19
|
+
return m.request({url: url, method: 'GET'})
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
var FavouriteMaps = function(by_type){
|
24
|
+
for (type in by_type){
|
25
|
+
this[type] = by_type[type]
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
FavouriteMaps.get = function(){
|
30
|
+
return m.request({method: 'GET', url: '/favourite_entity_maps', type: FavouriteMaps, deserialize: FavouriteMaps.deserialize})
|
31
|
+
}
|
32
|
+
|
33
|
+
FavouriteMaps.deserialize = function(data){
|
34
|
+
data = JSON.parse(data)
|
35
|
+
favourite_maps = {}
|
36
|
+
for (type in data){
|
37
|
+
var type_data = data[type]
|
38
|
+
favourite_maps[type] = {}
|
39
|
+
for (column in type_data){
|
40
|
+
var column_data = type_data[column]
|
41
|
+
for (i in column_data){
|
42
|
+
var info = {}
|
43
|
+
id = column_data[i]
|
44
|
+
info.id = id
|
45
|
+
info.column = column
|
46
|
+
info.type = type
|
47
|
+
favourite_maps[type][id] = new EntityMap(info)
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return favourite_maps
|
52
|
+
}
|
@@ -0,0 +1,286 @@
|
|
1
|
+
|
2
|
+
rbbt.favourites = {};
|
3
|
+
var fav_module = rbbt.favourites;
|
4
|
+
|
5
|
+
fav_module.entities = {types: m.prop({})}
|
6
|
+
fav_module.entities.init = function(){
|
7
|
+
return FavouriteEntities.get().then(fav_module.entities.types)
|
8
|
+
}
|
9
|
+
|
10
|
+
fav_module.lists = {types: m.prop({})}
|
11
|
+
fav_module.lists.init = function(){
|
12
|
+
return FavouriteLists.get().then(fav_module.lists.types)
|
13
|
+
}
|
14
|
+
|
15
|
+
fav_module.maps = {types: m.prop({})}
|
16
|
+
fav_module.maps.init = function(){
|
17
|
+
return FavouriteMaps.get().then(fav_module.maps.types)
|
18
|
+
}
|
19
|
+
|
20
|
+
fav_module.update_favourites = function(){
|
21
|
+
return m.sync([fav_module.lists.init(), fav_module.entities.init(), fav_module.maps.init()])
|
22
|
+
}
|
23
|
+
|
24
|
+
fav_module.isFavourite_entity = function(entity){
|
25
|
+
return fav_module.entities.types()[entity.type] !== undefined && fav_module.entities.types()[entity.type][entity.code] !== undefined
|
26
|
+
}
|
27
|
+
|
28
|
+
fav_module.isFavourite_list = function(list){
|
29
|
+
return fav_module.lists.types()[list.type] !== undefined && fav_module.lists.types()[list.type][list.id] !== undefined
|
30
|
+
}
|
31
|
+
|
32
|
+
fav_module.isFavourite_map = function(map){
|
33
|
+
return fav_module.maps.types()[map.type] !== undefined && fav_module.maps.types()[map.type][map.id] !== undefined
|
34
|
+
}
|
35
|
+
|
36
|
+
//{{{ TOGGLE
|
37
|
+
|
38
|
+
fav_module.toggleFavourite_entity = function(){
|
39
|
+
var entity = rbbt.page.entity();
|
40
|
+
|
41
|
+
if (fav_module.isFavourite_entity(entity)){
|
42
|
+
rbbt.post({url: '/remove_favourite_entity/' + entity.type + '/' + entity.code}).then(fav_module.update)
|
43
|
+
}else{
|
44
|
+
rbbt.post({url: '/add_favourite_entity/' + entity.type + '/' + entity.code, data: entity.info}).then(fav_module.update)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
fav_module.toggleFavourite_list = function(){
|
49
|
+
var list = rbbt.page.list();
|
50
|
+
|
51
|
+
if (fav_module.isFavourite_list(list)){
|
52
|
+
rbbt.post({url: '/remove_favourite_entity_list/' + list.type + '/' + list.id}).then(fav_module.update)
|
53
|
+
}else{
|
54
|
+
rbbt.post({url: '/add_favourite_entity_list/' + list.type + '/' + list.id}).then(fav_module.update)
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
fav_module.toggleFavourite_map = function(){
|
59
|
+
var map = rbbt.page.map();
|
60
|
+
|
61
|
+
if (fav_module.isFavourite_map(map)){
|
62
|
+
rbbt.post({url: '/remove_favourite_entity_map/' + map.type + '/' + map.column + '/' + map.id}).then(fav_module.update)
|
63
|
+
}else{
|
64
|
+
rbbt.post({url: '/add_favourite_entity_map/' + map.type + '/' + map.column + '/' + map.id}).then(fav_module.update)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
fav_module.toggleFavourite = function(){
|
69
|
+
if (! rbbt.page.entity())
|
70
|
+
if (! rbbt.page.list())
|
71
|
+
if (! rbbt.page.map())
|
72
|
+
return
|
73
|
+
else
|
74
|
+
fav_module.toggleFavourite_map()
|
75
|
+
else
|
76
|
+
fav_module.toggleFavourite_list()
|
77
|
+
else
|
78
|
+
fav_module.toggleFavourite_entity()
|
79
|
+
}
|
80
|
+
|
81
|
+
//{{{ VIEWS
|
82
|
+
|
83
|
+
fav_module.star_view = function(){
|
84
|
+
if (! rbbt.page.entity())
|
85
|
+
if (! rbbt.page.list())
|
86
|
+
if (! rbbt.page.map())
|
87
|
+
return
|
88
|
+
else
|
89
|
+
return m('i.icon.star', {class: (fav_module.isFavourite_map(rbbt.page.map()) ? 'favourite' : 'not_favourite')})
|
90
|
+
else
|
91
|
+
return m('i.icon.star', {class: (fav_module.isFavourite_list(rbbt.page.list()) ? 'favourite' : 'not_favourite')})
|
92
|
+
else
|
93
|
+
return m('i.icon.star', {class: (fav_module.isFavourite_entity(rbbt.page.entity()) ? 'favourite' : 'not_favourite')})
|
94
|
+
}
|
95
|
+
|
96
|
+
fav_module.draw_favourite_menu = function(){
|
97
|
+
var favourites = fav_module.entities.types()
|
98
|
+
var types = Object.keys(favourites)
|
99
|
+
|
100
|
+
return m('.ui.menu',
|
101
|
+
m('.ui.dropdown.item', [
|
102
|
+
m('i.icon.dropdown'),
|
103
|
+
'Entities',
|
104
|
+
m('.menu', [m('a.item',{onclick: fav_module.highlight}, 'highlight')].concat(types.map(function(type, index){
|
105
|
+
var _type = favourites[type]
|
106
|
+
var entities = Object.keys(_type)
|
107
|
+
|
108
|
+
return m('.ui.dropdown.item', [
|
109
|
+
m('i.icon.dropdown'),
|
110
|
+
type,
|
111
|
+
m('.menu', entities.map(function(entity, index){ url = _type[entity].url(); return m('a.item', {href: url}, _type[entity].name) }))
|
112
|
+
]);
|
113
|
+
})))
|
114
|
+
])
|
115
|
+
)
|
116
|
+
}
|
117
|
+
|
118
|
+
fav_module.draw_favourite_list_menu = function(){
|
119
|
+
var favourites = fav_module.lists.types()
|
120
|
+
var types = Object.keys(favourites)
|
121
|
+
|
122
|
+
return m('.ui.menu',
|
123
|
+
m('.ui.dropdown.item', [
|
124
|
+
m('i.icon.dropdown'),
|
125
|
+
'Lists',
|
126
|
+
m('.menu', types.map(function(type, index){
|
127
|
+
var _type = favourites[type]
|
128
|
+
var lists = Object.keys(_type)
|
129
|
+
|
130
|
+
return m('.ui.dropdown.item', [
|
131
|
+
m('i.icon.dropdown'),
|
132
|
+
type,
|
133
|
+
m('.menu', lists.map(function(list, index){
|
134
|
+
url = _type[list].url()
|
135
|
+
var link = m('a.item', {href: url, style: 'display: inline-block; width: 100%'}, _type[list].name)
|
136
|
+
//return [link, m('span.bullet.green', {onclick: function(){_type[list].highlight('green'); return false}},''),m('br')]
|
137
|
+
return [link, m('span.bullet.green', {onclick: function(){_type[list].highlight('green'); return false}},''),m('br')]
|
138
|
+
}))
|
139
|
+
]);
|
140
|
+
}))
|
141
|
+
])
|
142
|
+
)
|
143
|
+
}
|
144
|
+
|
145
|
+
fav_module.draw_favourite_map_menu = function(){
|
146
|
+
var favourites = fav_module.maps.types()
|
147
|
+
var types = Object.keys(favourites)
|
148
|
+
|
149
|
+
return m('.ui.menu',
|
150
|
+
m('.ui.dropdown.item', [
|
151
|
+
m('i.icon.dropdown'),
|
152
|
+
'Maps',
|
153
|
+
m('.menu', types.map(function(type, index){
|
154
|
+
var _type = favourites[type]
|
155
|
+
var maps = Object.keys(_type)
|
156
|
+
|
157
|
+
return m('.ui.dropdown.item', [
|
158
|
+
m('i.icon.dropdown'),
|
159
|
+
type,
|
160
|
+
m('.menu', maps.map(function(map, index){
|
161
|
+
url = _type[map].url()
|
162
|
+
var link = m('a.item', {href: url, _style: 'display: inline-block;width:100%'}, _type[map].name)
|
163
|
+
//return [link, m('span.bullet.green', {onclick: function(){_type[map].highlight('green'); return false}},''),m('br')]
|
164
|
+
return link
|
165
|
+
}))
|
166
|
+
]);
|
167
|
+
}))
|
168
|
+
])
|
169
|
+
)
|
170
|
+
}
|
171
|
+
|
172
|
+
fav_module.view = function(){
|
173
|
+
m.render($('#top_menu > .favourite')[0], [
|
174
|
+
m('.item.pointer', {onclick: fav_module.toggleFavourite}, fav_module.star_view()),
|
175
|
+
m('.item', {style: 'padding: 0px'}, fav_module.draw_favourite_menu()),
|
176
|
+
m('.item', {style: 'padding: 0px'}, fav_module.draw_favourite_list_menu()),
|
177
|
+
m('.item', {style: 'padding: 0px'}, fav_module.draw_favourite_map_menu())
|
178
|
+
])
|
179
|
+
}
|
180
|
+
|
181
|
+
//{{{ HOOKS
|
182
|
+
|
183
|
+
fav_module._update_list_select= function(select, type, lists){
|
184
|
+
if (select.attr('attr-allow-empty') == 'true'){
|
185
|
+
var option = $('<option value="none" class="loaded">none</option>')
|
186
|
+
select.append(option);
|
187
|
+
}
|
188
|
+
|
189
|
+
var selected = null;
|
190
|
+
|
191
|
+
if (select.attr('attr-selected') != undefined ){
|
192
|
+
selected = select.attr('attr-selected');
|
193
|
+
}
|
194
|
+
|
195
|
+
$.each(lists, function(name, elems){
|
196
|
+
var option = null;
|
197
|
+
var name = elems
|
198
|
+
if (selected == null || name != selected){
|
199
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" value="' + name.id + '">' + name.id + '</option>');
|
200
|
+
}else{
|
201
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" selected=selected value="' + name.id + '">' + name.id + '</option>');
|
202
|
+
}
|
203
|
+
select.append(option);
|
204
|
+
return true
|
205
|
+
})
|
206
|
+
},
|
207
|
+
|
208
|
+
fav_module.update_list_selects= function(){
|
209
|
+
$('select.favourite_lists').find('option.automatic_load').remove()
|
210
|
+
|
211
|
+
$.each(fav_module.lists.types(), function(type, lists){
|
212
|
+
$('select.favourite_lists[type=' + type + ']').each(function(){
|
213
|
+
var select = $(this);
|
214
|
+
fav_module._update_list_select(select, type, lists);
|
215
|
+
})
|
216
|
+
$('select.favourite_lists[type=All]').each(function(){
|
217
|
+
var select = $(this);
|
218
|
+
select.append($('<option class="automatic_load ui" disabled>'+ type +'</option>'));
|
219
|
+
fav_module._update_list_select(select, type, lists);
|
220
|
+
})
|
221
|
+
});
|
222
|
+
}
|
223
|
+
|
224
|
+
fav_module._update_map_select= function(select, type, maps){
|
225
|
+
if (select.attr('attr-allow-empty') == 'true'){
|
226
|
+
var option = $('<option value="none" class="loaded">none</option>')
|
227
|
+
select.append(option);
|
228
|
+
}
|
229
|
+
|
230
|
+
var selected = null;
|
231
|
+
|
232
|
+
if (select.attr('attr-selected') != undefined ){
|
233
|
+
selected = select.attr('attr-selected');
|
234
|
+
}
|
235
|
+
|
236
|
+
console.log(maps)
|
237
|
+
$.each(maps, function(name, elems){
|
238
|
+
var option = null;
|
239
|
+
var name = elems
|
240
|
+
if (selected == null || name != selected){
|
241
|
+
option = $('<option attr-column="' + name.column + '" attr-entity_type="' + name.type + '" class="automatic_load" value="' + name.id + '">' + name.id + '</option>');
|
242
|
+
}else{
|
243
|
+
option = $('<option attr-column="' + name.column + '" attr-entity_type="' + name.type + '" class="automatic_load" selected=selected value="' + name.id + '">' + name.id + '</option>');
|
244
|
+
}
|
245
|
+
select.append(option);
|
246
|
+
return true
|
247
|
+
})
|
248
|
+
},
|
249
|
+
|
250
|
+
fav_module.update_map_selects= function(){
|
251
|
+
$('select.favourite_maps').find('option.automatic_load').remove()
|
252
|
+
|
253
|
+
$.each(fav_module.maps.types(), function(type, maps){
|
254
|
+
$('select.favourite_maps[type=' + type + ']').each(function(){
|
255
|
+
var select = $(this);
|
256
|
+
fav_module._update_map_select(select, type, maps);
|
257
|
+
})
|
258
|
+
$('select.favourite_maps[type=All]').each(function(){
|
259
|
+
var select = $(this);
|
260
|
+
select.append($('<option class="automatic_load ui" disabled>'+ type +'</option>'));
|
261
|
+
fav_module._update_map_select(select, type, maps);
|
262
|
+
})
|
263
|
+
});
|
264
|
+
}
|
265
|
+
|
266
|
+
fav_module.highlight = function(){
|
267
|
+
var targets = []
|
268
|
+
for (type in fav_module.entities.types()){
|
269
|
+
var _type = fav_module.entities.types()[type]
|
270
|
+
var n = Object.keys(_type)
|
271
|
+
var nt = n.map(function(e){ return _type[e].id})
|
272
|
+
targets = targets.concat(nt)
|
273
|
+
}
|
274
|
+
rbbt.aesthetics.apply_aesthetic({selector: targets, aes: 'color', value: 'gold'})
|
275
|
+
}
|
276
|
+
|
277
|
+
fav_module.hooks = function(){
|
278
|
+
fav_module.update_list_selects()
|
279
|
+
fav_module.update_map_selects()
|
280
|
+
}
|
281
|
+
|
282
|
+
fav_module.update = function(){
|
283
|
+
fav_module.update_favourites().then(fav_module.view).then(function(){ $('.dropdown:not([tabindex])').dropdown()}).then(fav_module.hooks)
|
284
|
+
}
|
285
|
+
|
286
|
+
fav_module.update()
|