mirror of https://github.com/RubaXa/Sortable.git
RubaXa
10 years ago
17 changed files with 130 additions and 75 deletions
@ -0,0 +1,8 @@ |
|||||||
|
# This file contains information which helps Meteor properly upgrade your |
||||||
|
# app when you run 'meteor update'. You should check it into version control |
||||||
|
# with your project. |
||||||
|
|
||||||
|
notices-for-0.9.0 |
||||||
|
notices-for-0.9.1 |
||||||
|
0.9.4-platform-file |
||||||
|
notices-for-facebook-graph-api-2 |
@ -0,0 +1,7 @@ |
|||||||
|
# This file contains a token that is unique to your project. |
||||||
|
# Check it into your repository along with the rest of this directory. |
||||||
|
# It can be used for purposes such as: |
||||||
|
# - ensuring you don't accidentally deploy one app on top of another |
||||||
|
# - providing package authors with aggregated statistics |
||||||
|
|
||||||
|
ir0jg2douy3yo5mehw |
@ -1,56 +1,53 @@ |
|||||||
application-configuration@1.0.3 |
autopublish@1.0.3 |
||||||
autopublish@1.0.1 |
autoupdate@1.2.1 |
||||||
autoupdate@1.1.3 |
base64@1.0.3 |
||||||
base64@1.0.1 |
binary-heap@1.0.3 |
||||||
binary-heap@1.0.1 |
blaze@2.1.2 |
||||||
blaze-tools@1.0.1 |
blaze-tools@1.0.3 |
||||||
blaze@2.0.3 |
boilerplate-generator@1.0.3 |
||||||
boilerplate-generator@1.0.1 |
callback-hook@1.0.3 |
||||||
callback-hook@1.0.1 |
check@1.0.5 |
||||||
check@1.0.2 |
dburles:mongo-collection-instances@0.3.3 |
||||||
ctl-helper@1.0.4 |
ddp@1.1.0 |
||||||
ctl@1.0.2 |
deps@1.0.7 |
||||||
dburles:mongo-collection-instances@0.2.5 |
ejson@1.0.6 |
||||||
ddp@1.0.12 |
fastclick@1.0.3 |
||||||
deps@1.0.5 |
fezvrasta:bootstrap-material-design@0.3.0 |
||||||
ejson@1.0.4 |
geojson-utils@1.0.3 |
||||||
fastclick@1.0.1 |
html-tools@1.0.4 |
||||||
fezvrasta:bootstrap-material-design@0.2.1 |
htmljs@1.0.4 |
||||||
follower-livedata@1.0.2 |
http@1.1.0 |
||||||
geojson-utils@1.0.1 |
id-map@1.0.3 |
||||||
html-tools@1.0.2 |
insecure@1.0.3 |
||||||
htmljs@1.0.2 |
jquery@1.11.3_2 |
||||||
http@1.0.8 |
json@1.0.3 |
||||||
id-map@1.0.1 |
lai:collection-extensions@0.1.3 |
||||||
insecure@1.0.1 |
launch-screen@1.0.2 |
||||||
jquery@1.0.1 |
livedata@1.0.13 |
||||||
json@1.0.1 |
logging@1.0.7 |
||||||
launch-screen@1.0.0 |
meteor@1.1.6 |
||||||
livedata@1.0.11 |
meteor-platform@1.2.2 |
||||||
logging@1.0.5 |
minifiers@1.1.5 |
||||||
meteor-platform@1.2.0 |
minimongo@1.0.8 |
||||||
meteor@1.1.3 |
mobile-status-bar@1.0.3 |
||||||
minifiers@1.1.2 |
mongo@1.1.0 |
||||||
minimongo@1.0.5 |
observe-sequence@1.0.6 |
||||||
mobile-status-bar@1.0.1 |
ordered-dict@1.0.3 |
||||||
mongo@1.0.9 |
random@1.0.3 |
||||||
observe-sequence@1.0.3 |
reactive-dict@1.1.0 |
||||||
ordered-dict@1.0.1 |
reactive-var@1.0.5 |
||||||
random@1.0.1 |
reload@1.1.3 |
||||||
reactive-dict@1.0.4 |
retry@1.0.3 |
||||||
reactive-var@1.0.3 |
routepolicy@1.0.5 |
||||||
reload@1.1.1 |
rubaxa:sortable@1.2.0 |
||||||
retry@1.0.1 |
session@1.1.0 |
||||||
routepolicy@1.0.2 |
spacebars@1.0.6 |
||||||
rubaxa:sortable@1.0.0 |
spacebars-compiler@1.0.6 |
||||||
session@1.0.4 |
templating@1.1.1 |
||||||
spacebars-compiler@1.0.3 |
tracker@1.0.7 |
||||||
spacebars@1.0.3 |
twbs:bootstrap@3.3.4 |
||||||
templating@1.0.9 |
ui@1.0.6 |
||||||
tracker@1.0.3 |
underscore@1.0.3 |
||||||
twbs:bootstrap@3.3.1 |
url@1.0.4 |
||||||
ui@1.0.4 |
webapp@1.2.0 |
||||||
underscore@1.0.1 |
webapp-hashing@1.0.3 |
||||||
url@1.0.2 |
|
||||||
webapp-hashing@1.0.1 |
|
||||||
webapp@1.1.4 |
|
||||||
|
@ -0,0 +1,3 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
Sortable.collections = ['attributes']; |
@ -0,0 +1,31 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
Sortable = {}; |
||||||
|
Sortable.collections = []; // array of collection names that the client is allowed to reorder
|
||||||
|
|
||||||
|
Meteor.methods({ |
||||||
|
/** |
||||||
|
* Update the sortField of documents with given ids in a collection, incrementing it by incDec |
||||||
|
* @param {String} collectionName - name of the collection to update |
||||||
|
* @param {String[]} ids - array of document ids |
||||||
|
* @param {String} orderField - the name of the order field, usually "order" |
||||||
|
* @param {Number} incDec - pass 1 or -1 |
||||||
|
*/ |
||||||
|
'rubaxa:sortable/collection-update': function (collectionName, ids, sortField, incDec) { |
||||||
|
check(collectionName, String); |
||||||
|
// don't allow the client to modify just any collection
|
||||||
|
if (!Sortable || !Array.isArray(Sortable.collections)) { |
||||||
|
throw new Meteor.Error(500, 'Please define Sortable.collections'); |
||||||
|
} |
||||||
|
if (Sortable.collections.indexOf(collectionName) === -1) { |
||||||
|
throw new Meteor.Error(403, 'Collection <' + collectionName + '> is not Sortable. Please add it to Sortable.collections in server code.'); |
||||||
|
} |
||||||
|
|
||||||
|
check(ids, [String]); |
||||||
|
check(sortField, String); |
||||||
|
check(incDec, Number); |
||||||
|
var selector = {_id: {$in: ids}}, modifier = {$inc: {}}; |
||||||
|
modifier.$inc[sortField] = incDec; |
||||||
|
Mongo.Collection.get(collectionName).update(selector, modifier, {multi: true}); |
||||||
|
} |
||||||
|
}); |
Loading…
Reference in new issue