-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed gallery to collection picture add (view + controller) image grid ui tweaks Signed-off-by: Christian Roth <christian.roth@port17.de>
- Loading branch information
Showing
71 changed files
with
885 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
Mmh = require('mmh') | ||
|
||
Collection = require '../models/Collection' | ||
|
||
|
||
module.exports = class CollectionController extends Mmh.RestController | ||
|
||
get: ( req, res, next ) -> | ||
if req.params.id | ||
Collection.findById req.params.id, (err, collection) -> | ||
if err then return next new Error err | ||
if not collection then return next new Mmh.Error.NotFound "No collection with id #{req.params.id}" | ||
res.json collection | ||
else | ||
Collection.find (err, collections) -> | ||
if err then return next new Error err | ||
res.json collections | ||
|
||
|
||
post: ( req, res, next ) -> | ||
|
||
# delete read only props | ||
delete req.body.type | ||
delete req.body.user | ||
|
||
collection = new Collection req.body | ||
|
||
collection.user._id = req.user._id | ||
collection.user.name = req.user.name | ||
|
||
collection.save (err) -> | ||
if err then return next new Error err | ||
res.json collection | ||
|
||
|
||
put: ( req, res, next ) -> | ||
Collection.findById req.params.id, (err, collection) -> | ||
if err then return next new Error err | ||
|
||
collection.name = req.body.name | ||
collection.location = req.body.location | ||
collection.tags = req.body.tags | ||
|
||
collection.save (err) -> | ||
if err then return next new Error err | ||
res.json collection | ||
|
||
|
||
delete: ( req, res, next ) -> | ||
Collection.findById req.params.id, (err, collection) -> | ||
if err then return next new Error err | ||
|
||
collection.delete (err) -> | ||
if err then return next new Error err | ||
res.json code: 'ok' | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
mongoose = require 'mongoose' | ||
textSearch = require 'mongoose-text-search' | ||
|
||
|
||
CollectionSchema = new mongoose.Schema | ||
|
||
type: | ||
type: String | ||
default: 'collection' | ||
select: false | ||
|
||
name: | ||
type: String | ||
required: true | ||
unique: true | ||
|
||
description: String | ||
|
||
user: | ||
_id: | ||
type: mongoose.Schema.Types.ObjectId | ||
ref: 'User' | ||
name: String | ||
|
||
pictures: | ||
type: [mongoose.Schema.Types.ObjectId] | ||
ref: 'Picture' | ||
|
||
tags: | ||
type: [String] | ||
index: 'text' | ||
|
||
|
||
CollectionSchema.plugin textSearch | ||
|
||
module.exports = Collection = mongoose.model 'Collection', CollectionSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
define (require) -> | ||
'use strict' | ||
|
||
$ = require 'jquery' | ||
utils = require 'lib/utils' | ||
AuthController = require 'controllers/base/auth-controller' | ||
Collection = require 'models/collection' | ||
|
||
CollectionView = require 'views/collection/index-view' | ||
CollectionItemsView = require 'views/collection/items-view' | ||
NewCollectionView = require 'views/collection/new-view' | ||
|
||
class CollectionController extends AuthController | ||
|
||
show: (params) -> | ||
@adjustTitle 'Collection' | ||
|
||
@collection = new Collection _id: params.id | ||
@collection.fetch | ||
success: (collection) => | ||
@pictures = @collection.get('pictures') | ||
@pictures.id = '1234' | ||
@pictures.add id: num, url: "//lorempixel.com/1600/1200/?r=#{num}" for num in [1..40] | ||
|
||
@search = new CollectionView | ||
model: @gallery | ||
region: 'gallery' | ||
|
||
@pictures = new CollectionItemsView | ||
collection: @pictures | ||
region: 'images' | ||
preload: params.preload ? 10 | ||
|
||
utils.pageTransition $('#gallery'), 'right' | ||
|
||
error: (collection, error) => | ||
@publishEvent '!error', error | ||
|
||
|
||
create: (params) -> | ||
@adjustTitle 'a/Collection' | ||
|
||
@view = new NewCollectionView | ||
region: 'dynamic' | ||
|
||
utils.pageTransition $('#dynamic'), 'top' | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
define (require) -> | ||
'use strict' | ||
|
||
$ = require 'jquery' | ||
utils = require 'lib/utils' | ||
|
||
AuthController = require 'controllers/base/auth-controller' | ||
Collections = require 'models/collections' | ||
NewPictureView = require 'views/picture/new-view' | ||
|
||
|
||
class PictureController extends AuthController | ||
|
||
create: (params) -> | ||
@adjustTitle 'a/Picture' | ||
|
||
collections = new Collections | ||
collections.fetch() | ||
|
||
@view = new NewPictureView | ||
region: 'dynamic' | ||
collection: collections | ||
|
||
utils.pageTransition $('#dynamic'), 'top' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.