update lists on list change
This commit is contained in:
parent
c66433c740
commit
54d6d43fab
2 changed files with 26 additions and 8 deletions
|
@ -200,7 +200,7 @@ class Changelog(db.Model):
|
||||||
if name == '':
|
if name == '':
|
||||||
return True
|
return True
|
||||||
l = List.create(user.id, name)
|
l = List.create(user.id, name)
|
||||||
trigger_event('addlist', {'id': l.public_id})
|
trigger_event('addlist', {'id': l.public_id, 'user': user.id})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_editlist(self, user, timestamp, name, new):
|
def action_editlist(self, user, timestamp, name, new):
|
||||||
|
@ -209,7 +209,7 @@ class Changelog(db.Model):
|
||||||
if 'name' in new:
|
if 'name' in new:
|
||||||
l.name = new['name']
|
l.name = new['name']
|
||||||
l.save()
|
l.save()
|
||||||
trigger_event('editlist', {'id': l.public_id})
|
trigger_event('editlist', {'id': l.public_id, 'user': user.id})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_orderlists(self, user, timestamp, lists):
|
def action_orderlists(self, user, timestamp, lists):
|
||||||
|
@ -220,7 +220,7 @@ class Changelog(db.Model):
|
||||||
l.index_ = idx
|
l.index_ = idx
|
||||||
l.save()
|
l.save()
|
||||||
idx += 1
|
idx += 1
|
||||||
trigger_event('orderlists', {})
|
trigger_event('orderlists', {'user': user.id})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_removelist(self, user, timestamp, name):
|
def action_removelist(self, user, timestamp, name):
|
||||||
|
@ -356,7 +356,7 @@ class Changelog(db.Model):
|
||||||
new_id = data[2]['name']
|
new_id = data[2]['name']
|
||||||
r = revision
|
r = revision
|
||||||
if old_id not in changes.get('addlist', []):
|
if old_id not in changes.get('addlist', []):
|
||||||
action[old_id] = [revision, timestamp, new_id]
|
action[old_id] = [revision, timestamp, {'name': new_id}]
|
||||||
r += 1
|
r += 1
|
||||||
for a in ('addlist', 'addlistitems', 'removelistitems'):
|
for a in ('addlist', 'addlistitems', 'removelistitems'):
|
||||||
if a in changes and old_id in changes[a]:
|
if a in changes and old_id in changes[a]:
|
||||||
|
@ -448,10 +448,10 @@ class Changelog(db.Model):
|
||||||
if orderlists:
|
if orderlists:
|
||||||
ids = [l.name for l in List.query.filter_by(user_id=user_id,type='static').order_by('index_') if l.name]
|
ids = [l.name for l in List.query.filter_by(user_id=user_id,type='static').order_by('index_') if l.name]
|
||||||
if len(ids) > 1:
|
if len(ids) > 1:
|
||||||
_changes.append([-1, timestamp, ['orderlists', ids]])
|
_changes.append([-1, timestamp, json.dumps(['orderlists', ids])])
|
||||||
if _changes:
|
if _changes:
|
||||||
r = revision - len(_changes) + 1
|
r = revision
|
||||||
for c in _changes:
|
for c in reversed(_changes):
|
||||||
c[0] = r
|
c[0] = r
|
||||||
r += 1
|
r -= 1
|
||||||
return _changes
|
return _changes
|
||||||
|
|
|
@ -343,10 +343,28 @@ oml.ui.folders = function() {
|
||||||
that.updateItems();
|
that.updateItems();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
addlist: function(data) {
|
||||||
|
var index = Ox.getIndexById(ui._users, data.user);
|
||||||
|
if (index > -1) {
|
||||||
|
that.updateUser(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
Ox.print('got change event')
|
Ox.print('got change event')
|
||||||
Ox.Request.clearCache();
|
Ox.Request.clearCache();
|
||||||
},
|
},
|
||||||
|
editlist: function(data) {
|
||||||
|
var index = Ox.getIndexById(ui._users, data.user);
|
||||||
|
if (index > -1) {
|
||||||
|
that.updateUser(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
orderlists: function(data) {
|
||||||
|
var index = Ox.getIndexById(ui._users, data.user);
|
||||||
|
if (index > -1) {
|
||||||
|
that.updateUser(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
peering: function(data, event) {
|
peering: function(data, event) {
|
||||||
Ox.Request.clearCache('getUsers');
|
Ox.Request.clearCache('getUsers');
|
||||||
if (Ox.contains(['peering.accept', 'peering.remove'], event)) {
|
if (Ox.contains(['peering.accept', 'peering.remove'], event)) {
|
||||||
|
|
Loading…
Reference in a new issue