land place changes
This commit is contained in:
commit
5b222ef393
6 changed files with 261 additions and 52 deletions
|
@ -1,35 +1,151 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from django.db.models import Q, Manager
|
from django.db.models import Q, Manager
|
||||||
|
from ox.django.query import QuerySet
|
||||||
|
|
||||||
|
def parseCondition(condition, user):
|
||||||
|
'''
|
||||||
|
condition: {
|
||||||
|
value: "war"
|
||||||
|
}
|
||||||
|
or
|
||||||
|
condition: {
|
||||||
|
key: "year",
|
||||||
|
value: "1970-1980,
|
||||||
|
operator: "!="
|
||||||
|
}
|
||||||
|
...
|
||||||
|
'''
|
||||||
|
k = condition.get('key', 'name')
|
||||||
|
k = {
|
||||||
|
'user': 'user__username',
|
||||||
|
}.get(k, k)
|
||||||
|
if not k:
|
||||||
|
k = 'name'
|
||||||
|
v = condition['value']
|
||||||
|
op = condition.get('operator', None)
|
||||||
|
if not op:
|
||||||
|
op = ''
|
||||||
|
if op.startswith('!'):
|
||||||
|
op = op[1:]
|
||||||
|
exclude = True
|
||||||
|
else:
|
||||||
|
exclude = False
|
||||||
|
if k == 'id':
|
||||||
|
v = v.split('/')
|
||||||
|
if len(v) == 2:
|
||||||
|
q = Q(user__username=v[0], name=v[1])
|
||||||
|
else:
|
||||||
|
q = Q(id__in=[])
|
||||||
|
return q
|
||||||
|
if isinstance(v, bool): #featured and public flag
|
||||||
|
key = k
|
||||||
|
else:
|
||||||
|
if op == '=':
|
||||||
|
key = '%s__iexact'%k
|
||||||
|
elif op == '^':
|
||||||
|
v = v[1:]
|
||||||
|
key = '%s__istartswith'%k
|
||||||
|
elif op == '$':
|
||||||
|
v = v[:-1]
|
||||||
|
key = '%s__iendswith'%k
|
||||||
|
else: # default
|
||||||
|
key = '%s__icontains'%k
|
||||||
|
|
||||||
|
key = str(key)
|
||||||
|
if exclude:
|
||||||
|
q = ~Q(**{key: v})
|
||||||
|
else:
|
||||||
|
q = Q(**{key: v})
|
||||||
|
return q
|
||||||
|
|
||||||
|
def parseConditions(conditions, operator, user):
|
||||||
|
'''
|
||||||
|
conditions: [
|
||||||
|
{
|
||||||
|
value: "war"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key: "year",
|
||||||
|
value: "1970-1980,
|
||||||
|
operator: "!="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "country",
|
||||||
|
value: "f",
|
||||||
|
operator: "^"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
operator: "&"
|
||||||
|
'''
|
||||||
|
conn = []
|
||||||
|
for condition in conditions:
|
||||||
|
if 'conditions' in condition:
|
||||||
|
q = parseConditions(condition['conditions'],
|
||||||
|
condition.get('operator', '&'), user)
|
||||||
|
if q:
|
||||||
|
conn.append(q)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if condition.get('value', '') != '' or \
|
||||||
|
condition.get('operator', '') == '=':
|
||||||
|
conn.append(parseCondition(condition, user))
|
||||||
|
if conn:
|
||||||
|
q = conn[0]
|
||||||
|
for c in conn[1:]:
|
||||||
|
if operator == '|':
|
||||||
|
q = q | c
|
||||||
|
else:
|
||||||
|
q = q & c
|
||||||
|
return q
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PlaceManager(Manager):
|
class PlaceManager(Manager):
|
||||||
|
|
||||||
def get_query_set(self):
|
def get_query_set(self):
|
||||||
return super(PlaceManager, self).get_query_set()
|
return QuerySet(self.model)
|
||||||
|
|
||||||
def find(self, q='', south=-180.0, west=-180.0, north=180.0, east=180.0):
|
def find(self, data, user):
|
||||||
|
'''
|
||||||
|
query: {
|
||||||
|
conditions: [
|
||||||
|
{
|
||||||
|
value: "war"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key: "year",
|
||||||
|
value: "1970-1980,
|
||||||
|
operator: "!="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "country",
|
||||||
|
value: "f",
|
||||||
|
operator: "^"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
operator: "&"
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
#join query with operator
|
||||||
qs = self.get_query_set()
|
qs = self.get_query_set()
|
||||||
|
|
||||||
|
south=data['area']['south']
|
||||||
|
west=data['area']['west']
|
||||||
|
north=data['area']['north']
|
||||||
|
east=data['area']['east']
|
||||||
qs = qs.filter(Q(
|
qs = qs.filter(Q(
|
||||||
Q(Q(south__gt=south)|Q(south__lt=north)|Q(west__gt=west)|Q(west__lt=east)) &
|
Q(Q(south__gt=south)|Q(south__lt=north)|Q(west__gt=west)|Q(west__lt=east)) &
|
||||||
Q(Q(south__gt=south)|Q(south__lt=north)|Q(west__lt=east)|Q(east__gt=east)) &
|
Q(Q(south__gt=south)|Q(south__lt=north)|Q(west__lt=east)|Q(east__gt=east)) &
|
||||||
Q(Q(north__gt=south)|Q(north__lt=north)|Q(west__gt=west)|Q(west__lt=east)) &
|
Q(Q(north__gt=south)|Q(north__lt=north)|Q(west__gt=west)|Q(west__lt=east)) &
|
||||||
Q(Q(north__gt=south)|Q(north__lt=north)|Q(east__gt=west)|Q(east__lt=east))
|
Q(Q(north__gt=south)|Q(north__lt=north)|Q(east__gt=west)|Q(east__lt=east))
|
||||||
))
|
))
|
||||||
if q:
|
|
||||||
qs = qs.filter(name_find__icontains=q)
|
conditions = parseConditions(data['query'].get('conditions', []),
|
||||||
|
data['query'].get('operator', '&'),
|
||||||
|
user)
|
||||||
|
if conditions:
|
||||||
|
qs = qs.filter(conditions)
|
||||||
return qs
|
return qs
|
||||||
'''
|
|
||||||
#only return locations that have layers of videos visible to current user
|
|
||||||
if not identity.current.anonymous:
|
|
||||||
user = identity.current.user
|
|
||||||
if not user.in_group('admin'):
|
|
||||||
query = AND(query,
|
|
||||||
id == Layer.q.locationID, Layer.q.videoID == Video.q.id,
|
|
||||||
OR(Video.q.public == True, Video.q.creatorID == user.id)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
query = AND(query,
|
|
||||||
id == Layer.q.locationID, Layer.q.videoID == Video.q.id,
|
|
||||||
Video.q.public == True)
|
|
||||||
'''
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ class Place(models.Model):
|
||||||
|
|
||||||
geoname = models.CharField(max_length=1024, unique=True)
|
geoname = models.CharField(max_length=1024, unique=True)
|
||||||
geoname_sort = models.CharField(max_length=1024, unique=True)
|
geoname_sort = models.CharField(max_length=1024, unique=True)
|
||||||
|
countryCode = models.CharField(max_length=16, default='')
|
||||||
|
|
||||||
wikipediaId = models.CharField(max_length=1000, blank=True)
|
wikipediaId = models.CharField(max_length=1000, blank=True)
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ class Place(models.Model):
|
||||||
'user': self.user.username,
|
'user': self.user.username,
|
||||||
}
|
}
|
||||||
for key in ('created', 'modified',
|
for key in ('created', 'modified',
|
||||||
'name', 'geoname',
|
'name', 'geoname', 'countryCode',
|
||||||
'south', 'west', 'north', 'east',
|
'south', 'west', 'north', 'east',
|
||||||
'lat', 'lng', 'size'):
|
'lat', 'lng', 'size'):
|
||||||
j[key] = getattr(self, key)
|
j[key] = getattr(self, key)
|
||||||
|
|
|
@ -21,6 +21,7 @@ def addPlace(request):
|
||||||
param data {
|
param data {
|
||||||
name: "",
|
name: "",
|
||||||
geoname: "",
|
geoname: "",
|
||||||
|
countryCode: '',
|
||||||
south: float,
|
south: float,
|
||||||
west: float,
|
west: float,
|
||||||
north: float,
|
north: float,
|
||||||
|
@ -45,7 +46,7 @@ def addPlace(request):
|
||||||
for key in data:
|
for key in data:
|
||||||
setattr(place, key, data[key])
|
setattr(place, key, data[key])
|
||||||
place.save()
|
place.save()
|
||||||
response = json_response(status=200, text='created')
|
response = json_response(place.json())
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='place name exists')
|
response = json_response(status=403, text='place name exists')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
@ -72,14 +73,17 @@ def editPlace(request):
|
||||||
for name in names:
|
for name in names:
|
||||||
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0:
|
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0:
|
||||||
conflict = True
|
conflict = True
|
||||||
|
if 'geoname' in data:
|
||||||
|
if models.Place.objects.filter(geoname=data['geoname']).exclude(id=place.id).count() != 0:
|
||||||
|
conflict = True
|
||||||
if not conflict:
|
if not conflict:
|
||||||
for key in data:
|
for key in data:
|
||||||
if key != 'id':
|
if key != 'id':
|
||||||
setattr(place, key, data[key])
|
setattr(place, key, data[key])
|
||||||
place.save()
|
place.save()
|
||||||
response = json_response(status=200, text='updated')
|
response = json_response(place.json())
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='place name/alias conflict')
|
response = json_response(status=403, text='place name/geoname conflict')
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
@ -108,13 +112,30 @@ actions.register(removePlace, cache=False)
|
||||||
def parse_query(data, user):
|
def parse_query(data, user):
|
||||||
query = {}
|
query = {}
|
||||||
query['range'] = [0, 100]
|
query['range'] = [0, 100]
|
||||||
query['sort'] = [{'key':'user', 'operator':'+'}, {'key':'name', 'operator':'+'}]
|
query['sort'] = [{'key':'name', 'operator':'+'}]
|
||||||
for key in ('keys', 'group', 'list', 'range', 'ids', 'sort'):
|
query['area'] = {'south': -180.0, 'west': -180.0, 'north': 180.0, 'east': 180.0}
|
||||||
|
for key in ('area', 'keys', 'group', 'list', 'range', 'ids', 'sort', 'query'):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Place.objects.all()
|
query['qs'] = models.Place.objects.find(query, user)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
def order_query(qs, sort):
|
||||||
|
order_by = []
|
||||||
|
for e in sort:
|
||||||
|
operator = e['operator']
|
||||||
|
if operator != '-':
|
||||||
|
operator = ''
|
||||||
|
key = {
|
||||||
|
'name': 'name_sort',
|
||||||
|
'geoname': 'geoname_sort',
|
||||||
|
}.get(e['key'], e['key'])
|
||||||
|
order = '%s%s' % (operator, key)
|
||||||
|
order_by.append(order)
|
||||||
|
if order_by:
|
||||||
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
|
return qs
|
||||||
|
|
||||||
def findPlaces(request):
|
def findPlaces(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
|
@ -185,7 +206,7 @@ Positions
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
qs = query['qs']
|
qs = order_query(query['qs'], query['sort'])
|
||||||
if 'keys' in data:
|
if 'keys' in data:
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs[query['range'][0]:query['range'][1]]
|
||||||
response['data']['items'] = [p.json(request.user) for p in qs]
|
response['data']['items'] = [p.json(request.user) for p in qs]
|
||||||
|
|
|
@ -17,6 +17,7 @@ if(typeof(console)=='undefined') {
|
||||||
<script type="text/javascript" src="/static/oxjs/build/js/ox.load.js"></script>
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.load.js"></script>
|
||||||
<script type="text/javascript" src="/static/oxjs/build/js/ox.js"></script>
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.js"></script>
|
||||||
<script type="text/javascript" src="/static/oxjs/build/js/ox.ui.js"></script>
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.ui.js"></script>
|
||||||
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.map.js"></script><!-- fixme: lazyload -->
|
||||||
<script type="text/javascript" src="/static/js/pandora.js"></script>
|
<script type="text/javascript" src="/static/js/pandora.js"></script>
|
||||||
<!--
|
<!--
|
||||||
<script type="text/javascript" src="/static/js/pandora.local.js"></script> -->
|
<script type="text/javascript" src="/static/js/pandora.local.js"></script> -->
|
||||||
|
|
|
@ -79,7 +79,7 @@ function constructList() {
|
||||||
columnsMovable: false,
|
columnsMovable: false,
|
||||||
columnsRemovable: false,
|
columnsRemovable: false,
|
||||||
id: 'actionList',
|
id: 'actionList',
|
||||||
request: function(data, callback) {
|
items: function(data, callback) {
|
||||||
function _sort(a, b) {
|
function _sort(a, b) {
|
||||||
if(a.name > b.name)
|
if(a.name > b.name)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -571,16 +571,16 @@
|
||||||
width: ratio >= 1 ? size : size * ratio
|
width: ratio >= 1 ? size : size * ratio
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
keys: ['director', 'id', 'poster', 'title', 'year'],
|
items: function(data, callback) {
|
||||||
max: 1,
|
|
||||||
min: 1,
|
|
||||||
orientation: 'horizontal',
|
|
||||||
request: function(data, callback) {
|
|
||||||
//Ox.print('data, Query.toObject', data, Query.toObject())
|
//Ox.print('data, Query.toObject', data, Query.toObject())
|
||||||
pandora.api.find($.extend(data, {
|
pandora.api.find($.extend(data, {
|
||||||
query: Query.toObject()
|
query: Query.toObject()
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
|
keys: ['director', 'id', 'poster', 'title', 'year'],
|
||||||
|
max: 1,
|
||||||
|
min: 1,
|
||||||
|
orientation: 'horizontal',
|
||||||
selected: [app.user.ui.item],
|
selected: [app.user.ui.item],
|
||||||
size: 64,
|
size: 64,
|
||||||
sort: app.user.ui.lists[app.user.ui.list].sort,
|
sort: app.user.ui.lists[app.user.ui.list].sort,
|
||||||
|
@ -962,8 +962,7 @@
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
columnsVisible: true,
|
columnsVisible: true,
|
||||||
pageLength: 1000,
|
items: function(data, callback) {
|
||||||
request: function(data, callback) {
|
|
||||||
var query = id == 'favorite' ? {conditions: [
|
var query = id == 'favorite' ? {conditions: [
|
||||||
{key: 'user', value: app.user.username, operator: '!'},
|
{key: 'user', value: app.user.username, operator: '!'},
|
||||||
{key: 'status', value: 'public', operator: '='}
|
{key: 'status', value: 'public', operator: '='}
|
||||||
|
@ -975,6 +974,7 @@
|
||||||
query: query
|
query: query
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
|
pageLength: 1000,
|
||||||
// fixme: select if previously selected
|
// fixme: select if previously selected
|
||||||
// selected: app.user.ui.list ? [app.user.ui.list] : [],
|
// selected: app.user.ui.list ? [app.user.ui.list] : [],
|
||||||
sort: [
|
sort: [
|
||||||
|
@ -1062,9 +1062,7 @@
|
||||||
width: app.user.ui.sidebarSize - 16
|
width: app.user.ui.sidebarSize - 16
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
max: 1,
|
items: function(data, callback) {
|
||||||
min: 1,
|
|
||||||
request: function(data, callback) {
|
|
||||||
var result = {data: {}};
|
var result = {data: {}};
|
||||||
if (!data.range) {
|
if (!data.range) {
|
||||||
result.data.items = Ox.getObjectById(app.ui.sectionFolders.site, id).items.length;
|
result.data.items = Ox.getObjectById(app.ui.sectionFolders.site, id).items.length;
|
||||||
|
@ -1073,6 +1071,8 @@
|
||||||
}
|
}
|
||||||
callback(result);
|
callback(result);
|
||||||
},
|
},
|
||||||
|
max: 1,
|
||||||
|
min: 1,
|
||||||
sort: [{key: '', operator: ''}]
|
sort: [{key: '', operator: ''}]
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
@ -1165,10 +1165,7 @@
|
||||||
width: 16
|
width: 16
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
max: 1,
|
items: function(data, callback) {
|
||||||
min: 0,
|
|
||||||
pageLength: 1000,
|
|
||||||
request: function(data, callback) {
|
|
||||||
var query;
|
var query;
|
||||||
if (id == 'personal') {
|
if (id == 'personal') {
|
||||||
query = {conditions: [
|
query = {conditions: [
|
||||||
|
@ -1187,6 +1184,9 @@
|
||||||
query: query
|
query: query
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
|
max: 1,
|
||||||
|
min: 0,
|
||||||
|
pageLength: 1000,
|
||||||
sort: [
|
sort: [
|
||||||
{key: 'position', operator: '+'}
|
{key: 'position', operator: '+'}
|
||||||
],
|
],
|
||||||
|
@ -1535,7 +1535,7 @@
|
||||||
],
|
],
|
||||||
columnsVisible: true,
|
columnsVisible: true,
|
||||||
id: 'group_' + id,
|
id: 'group_' + id,
|
||||||
request: function(data, callback) {
|
items: function(data, callback) {
|
||||||
//Ox.print('sending request', data)
|
//Ox.print('sending request', data)
|
||||||
delete data.keys;
|
delete data.keys;
|
||||||
//alert(id + " Query.toObject " + JSON.stringify(Query.toObject(id)) + ' ' + JSON.stringify(data))
|
//alert(id + " Query.toObject " + JSON.stringify(Query.toObject(id)) + ' ' + JSON.stringify(data))
|
||||||
|
@ -1995,7 +1995,7 @@
|
||||||
columnsResizable: true,
|
columnsResizable: true,
|
||||||
columnsVisible: true,
|
columnsVisible: true,
|
||||||
id: 'list',
|
id: 'list',
|
||||||
request: function(data, callback) {
|
items: function(data, callback) {
|
||||||
//Ox.print('data, Query.toObject', data, Query.toObject())
|
//Ox.print('data, Query.toObject', data, Query.toObject())
|
||||||
pandora.api.find($.extend(data, {
|
pandora.api.find($.extend(data, {
|
||||||
query: Query.toObject()
|
query: Query.toObject()
|
||||||
|
@ -2042,13 +2042,13 @@
|
||||||
width: ratio >= 1 ? size : size * ratio
|
width: ratio >= 1 ? size : size * ratio
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
keys: ['director', 'id', 'poster', 'title', 'year'],
|
items: function(data, callback) {
|
||||||
request: function(data, callback) {
|
|
||||||
//Ox.print('data, Query.toObject', data, Query.toObject())
|
//Ox.print('data, Query.toObject', data, Query.toObject())
|
||||||
pandora.api.find($.extend(data, {
|
pandora.api.find($.extend(data, {
|
||||||
query: Query.toObject()
|
query: Query.toObject()
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
|
keys: ['director', 'id', 'poster', 'title', 'year'],
|
||||||
size: 128,
|
size: 128,
|
||||||
sort: app.user.ui.lists[app.user.ui.list].sort,
|
sort: app.user.ui.lists[app.user.ui.list].sort,
|
||||||
unique: 'id'
|
unique: 'id'
|
||||||
|
@ -2150,7 +2150,7 @@
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
})
|
})
|
||||||
.bindEvent('resize', function() {
|
.bindEvent('resize', function() {
|
||||||
app.$ui.map.triggerResize();
|
app.$ui.map.resize();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$list = new Ox.Element('<div>')
|
$list = new Ox.Element('<div>')
|
||||||
|
@ -2611,6 +2611,8 @@
|
||||||
app.$ui.accountDialog = (app.user.level == 'guest' ?
|
app.$ui.accountDialog = (app.user.level == 'guest' ?
|
||||||
ui.accountDialog('login') : ui.accountLogoutDialog()).open();
|
ui.accountDialog('login') : ui.accountLogoutDialog()).open();
|
||||||
} else if (data.id == 'places') {
|
} else if (data.id == 'places') {
|
||||||
|
app.$ui.placesDialog = ui.placesDialog().open();
|
||||||
|
/*
|
||||||
var $manage = new Ox.SplitPanel({
|
var $manage = new Ox.SplitPanel({
|
||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
|
@ -2727,7 +2729,7 @@
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
submit: function(event, data) {
|
submit: function(event, data) {
|
||||||
app.$ui.map.find(data.value, function(location) {
|
app.$ui.map.find(data.value, function(location) {
|
||||||
/*
|
|
||||||
app.$ui.placeNameInput.options({
|
app.$ui.placeNameInput.options({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
value: location.name
|
value: location.name
|
||||||
|
@ -2745,7 +2747,7 @@
|
||||||
app.$ui.addPlaceButton.options({
|
app.$ui.addPlaceButton.options({
|
||||||
disabled: false
|
disabled: false
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2882,6 +2884,7 @@
|
||||||
}).css({
|
}).css({
|
||||||
overflow: 'hidden'
|
overflow: 'hidden'
|
||||||
}).append($manage).open();
|
}).append($manage).open();
|
||||||
|
*/
|
||||||
} else if (data.id == 'query') {
|
} else if (data.id == 'query') {
|
||||||
var $dialog = new Ox.Dialog({
|
var $dialog = new Ox.Dialog({
|
||||||
buttons: [
|
buttons: [
|
||||||
|
@ -2932,6 +2935,73 @@
|
||||||
})
|
})
|
||||||
return that;
|
return that;
|
||||||
},
|
},
|
||||||
|
placesDialog: function() {
|
||||||
|
var height = Math.round(document.height * 0.8),
|
||||||
|
width = Math.round(document.width * 0.8),
|
||||||
|
that = new Ox.Dialog({
|
||||||
|
buttons: [
|
||||||
|
new Ox.Button({
|
||||||
|
id: 'done',
|
||||||
|
title: 'Done'
|
||||||
|
}).bindEvent({
|
||||||
|
click: function() {
|
||||||
|
that.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
content: app.$ui.placesElement = new Ox.ListMap({
|
||||||
|
height: height - 48,
|
||||||
|
places: function(data, callback) {
|
||||||
|
return pandora.api.findPlaces($.extend(data, {
|
||||||
|
query: {conditions: [], operator: ''}
|
||||||
|
}), callback);
|
||||||
|
},
|
||||||
|
width: width
|
||||||
|
})
|
||||||
|
.bindEvent({
|
||||||
|
addplace: function(event, data) {
|
||||||
|
Ox.print('ADDPLACE', data)
|
||||||
|
pandora.api.addPlace(data.place, function(result) {
|
||||||
|
var id = result.data.id;
|
||||||
|
Ox.print("ID", result.data.id, result)
|
||||||
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
|
Ox.print('AAAAA')
|
||||||
|
app.$ui.placesElement
|
||||||
|
.reloadList()
|
||||||
|
.bindEvent({loadlist: load});
|
||||||
|
Ox.print('BBBBB')
|
||||||
|
function load(event, data) {
|
||||||
|
Ox.print('LOAD')
|
||||||
|
app.$ui.placesElement
|
||||||
|
.focusList()
|
||||||
|
.options({selected: [id]})
|
||||||
|
.unbindEvent({loadlist: load}); // fixme: need bindEventOnce
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
removeplace: function(event, data) {
|
||||||
|
pandora.api.removePlace(data.id, function(result) {
|
||||||
|
// fixme: duplicated
|
||||||
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
|
app.$ui.placesElement
|
||||||
|
.reloadList()
|
||||||
|
.bindEvent({loadlist: load});
|
||||||
|
function load(event, data) {
|
||||||
|
app.$ui.placesElement
|
||||||
|
.focusList()
|
||||||
|
.unbindEvent({loadlist: load}); // fixme: need bindEventOnce
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
height: height,
|
||||||
|
keys: {enter: 'done', escape: 'done'},
|
||||||
|
padding: 0,
|
||||||
|
title: 'Manage Places',
|
||||||
|
width: width
|
||||||
|
});
|
||||||
|
return that;
|
||||||
|
},
|
||||||
publicListsDialog: function() { // fixme: unused
|
publicListsDialog: function() { // fixme: unused
|
||||||
var that = new Ox.Dialog({
|
var that = new Ox.Dialog({
|
||||||
buttons: [
|
buttons: [
|
||||||
|
@ -2994,7 +3064,7 @@
|
||||||
resizeGroups(data);
|
resizeGroups(data);
|
||||||
app.$ui.list.size();
|
app.$ui.list.size();
|
||||||
if (app.user.ui.lists[app.user.ui.list].listView == 'map') {
|
if (app.user.ui.lists[app.user.ui.list].listView == 'map') {
|
||||||
app.$ui.map.triggerResize();
|
app.$ui.map.resize();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.$ui.browser.scrollToSelection();
|
app.$ui.browser.scrollToSelection();
|
||||||
|
@ -3342,7 +3412,7 @@
|
||||||
function reloadGroups(i) {
|
function reloadGroups(i) {
|
||||||
var query = Query.toObject();
|
var query = Query.toObject();
|
||||||
app.$ui.list.options({
|
app.$ui.list.options({
|
||||||
request: function(data, callback) {
|
items: function(data, callback) {
|
||||||
return pandora.api.find($.extend(data, {
|
return pandora.api.find($.extend(data, {
|
||||||
query: query
|
query: query
|
||||||
}), callback);
|
}), callback);
|
||||||
|
@ -3352,7 +3422,7 @@
|
||||||
if (i_ != i) {
|
if (i_ != i) {
|
||||||
//Ox.print('setting groups request', i, i_)
|
//Ox.print('setting groups request', i, i_)
|
||||||
app.$ui.groups[i_].options({
|
app.$ui.groups[i_].options({
|
||||||
request: function(data, callback) {
|
items: function(data, callback) {
|
||||||
delete data.keys;
|
delete data.keys;
|
||||||
return pandora.api.find($.extend(data, {
|
return pandora.api.find($.extend(data, {
|
||||||
group: group_.id,
|
group: group_.id,
|
||||||
|
@ -3435,7 +3505,7 @@
|
||||||
app.$ui.list.size();
|
app.$ui.list.size();
|
||||||
resizeGroups(app.$ui.rightPanel.width());
|
resizeGroups(app.$ui.rightPanel.width());
|
||||||
if (app.user.ui.listView == 'map') {
|
if (app.user.ui.listView == 'map') {
|
||||||
app.$ui.map.triggerResize();
|
app.$ui.map.resize();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Ox.print('app.$ui.window.resize');
|
//Ox.print('app.$ui.window.resize');
|
||||||
|
|
Loading…
Reference in a new issue