This repository has been archived by the owner on Jun 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pending event sharing management and link it with the proxy
* Fetch sharings having rules with doctype 'event' and display a notification button in the calendar header * Do not list the shared event's calendar in menu * Do not list sharings already accepted * Handle realtime
- Loading branch information
1 parent
721a631
commit 99a1774
Showing
29 changed files
with
425 additions
and
25 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
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,11 @@ | ||
Sharing = require '../models/sharing' | ||
|
||
module.exports = class SharingCollection extends Backbone.Collection | ||
model: Sharing | ||
|
||
initialize: -> | ||
@on 'accepted refused', @onAnsweredSharing | ||
|
||
|
||
onAnsweredSharing: (sharing) -> | ||
@remove sharing |
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,18 @@ | ||
BaseView = require 'lib/base_view' | ||
|
||
# Represent a popup view | ||
module.exports = class PopupView extends BaseView | ||
|
||
initialize: (options) -> | ||
super | ||
@anchor = options.anchor | ||
|
||
|
||
hide: -> | ||
@$el.hide() | ||
@ | ||
|
||
|
||
toggle: (display)-> | ||
@$el.toggle display | ||
@ |
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
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,24 @@ | ||
request = require 'lib/request' | ||
|
||
|
||
module.exports = class Sharing extends Backbone.Model | ||
|
||
urlRoot: 'sharings' | ||
|
||
accept: (callback) -> | ||
id = @get 'id' | ||
request.post 'sharing/accept', @toJSON(), (err, response) => | ||
if err | ||
callback err, null | ||
else | ||
callback null, response | ||
@trigger 'accepted', @ | ||
|
||
refuse: (callback) -> | ||
id = @get 'id' | ||
request.post 'sharing/refuse', @toJSON(), (err, response) => | ||
if err | ||
callback err, null | ||
else | ||
callback null, response | ||
@trigger 'refused', @ |
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,17 @@ | ||
# Fix naming of ViewCollection Class to CollectionView | ||
CollectionView = require 'lib/view_collection' | ||
|
||
module.exports = class CollectionCounterView extends CollectionView | ||
|
||
className: 'collection-counter' | ||
template: require('./templates/collection_counter') | ||
|
||
|
||
initialize: (options) -> | ||
super options | ||
|
||
@stopListening @collection | ||
|
||
@listenTo @collection, 'add remove reset', @render | ||
|
||
afterRender: -> |
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,65 @@ | ||
# Fix naming of ViewCollection Class to CollectionView | ||
CollectionView = require 'lib/view_collection' | ||
CollectionCounterView = require './collection_counter' | ||
PopupView = require 'lib/popup_view' | ||
|
||
module.exports = class PendingEventSharingsButtonView extends CollectionView | ||
|
||
id: 'shared-events-button' | ||
template: require('./templates/pending_event_sharings_button') | ||
itemview: require('./pending_event_sharings_button_item') | ||
collectionEl: '#shared-events-popup' | ||
|
||
|
||
events: | ||
'click button': 'togglePopup' | ||
'keyup': 'onKeyUp' | ||
|
||
|
||
initialize: -> | ||
super() | ||
|
||
@counterView = new CollectionCounterView | ||
collection: @collection | ||
|
||
|
||
togglePopup: (display) -> | ||
@popup and @popup.toggle() | ||
|
||
|
||
render: -> | ||
super | ||
@counterView.snap(@).render() | ||
|
||
|
||
afterRender: -> | ||
if @collection.length then @$el.show() else @$el.hide() | ||
|
||
super | ||
|
||
@popup = new PopupView | ||
el: @$ @collectionEl | ||
anchor: @$el | ||
|
||
|
||
addItem: (model) -> | ||
@$el.show() | ||
super model | ||
|
||
|
||
removeItem: (model) -> | ||
super model | ||
|
||
if @collection.length == 0 | ||
@popup.hide() | ||
@$el.hide() | ||
|
||
|
||
onKeyUp: (event) -> | ||
keys = ESC: 27 | ||
if event.keyCode is keys.ESC | ||
@withdraw | ||
|
||
|
||
withdraw: -> | ||
@togglePopup(false) |
27 changes: 27 additions & 0 deletions
27
client/app/views/pending_event_sharings_button_item.coffee
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,27 @@ | ||
BaseView = require 'lib/base_view' | ||
|
||
module.exports = class PendingEventSharingsButtonItemView extends BaseView | ||
|
||
className: 'event-sharings-button-item' | ||
template: require './templates/pending_event_sharings_button_item' | ||
|
||
events: | ||
'click .accept': 'onAccept' | ||
'click .decline': 'onDecline' | ||
|
||
initialize: -> | ||
@listenTo @model, 'accepted refused', @destroy | ||
|
||
onAccept: -> | ||
@model.accept (err) => | ||
if err | ||
@onAnswerError err | ||
|
||
|
||
onDecline: -> | ||
@model.refuse (err) => | ||
if err | ||
@onAnswerError err | ||
|
||
onAnswerError: (err) -> | ||
console.error err |
Oops, something went wrong.