From 2c0e17cb977a1e8782799b337df8b1583d019906 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 12 Oct 2015 22:36:01 +0200 Subject: bootstraping react --- src/web/js/actions/MenuActions.js | 36 +++++++++++++++++++++ src/web/js/actions/MiddlePanelActions.js | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/web/js/actions/MenuActions.js create mode 100644 src/web/js/actions/MiddlePanelActions.js (limited to 'src/web/js/actions') diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js new file mode 100644 index 00000000..ce3a1030 --- /dev/null +++ b/src/web/js/actions/MenuActions.js @@ -0,0 +1,36 @@ +var JarrDispatcher = require('../dispatcher/JarrDispatcher'); +var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes; + + +var MenuActions = { + // PARENT FILTERS + reload: function() { + $.getJSON('/menu', function(payload) { + JarrDispatcher.dispatch({ + type: MenuActionTypes.RELOAD_MENU, + categories: payload.categories, + all_unread_count: payload.all_unread_count, + }); + }); + }, + setFilterMenuAll: function() { + JarrDispatcher.dispatch({ + component: 'menu', + type: MenuActionTypes.MENU_FILTER_ALL, + }); + }, + setFilterMenuUnread: function() { + JarrDispatcher.dispatch({ + component: 'menu', + type: MenuActionTypes.MENU_FILTER_UNREAD, + }); + }, + setFilterMenuError: function() { + JarrDispatcher.dispatch({ + type: MenuActionTypes.MENU_FILTER_ERROR, + }); + }, + +}; + +module.exports = MenuActions; diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js new file mode 100644 index 00000000..9877d0d5 --- /dev/null +++ b/src/web/js/actions/MiddlePanelActions.js @@ -0,0 +1,54 @@ +var JarrDispatcher = require('../dispatcher/JarrDispatcher'); +var MiddlePanelActionTypes = require('../constants/JarrConstants').MiddlePanelActionTypes; + + +var MiddlePanelActions = { + reload: function() { + $.getJSON('/middle_panel', function(payload) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.RELOAD_MIDDLE_PANEL, + articles: payload.articles, + }); + }); + }, + removeParentFilter: function(parent_type, parent_id) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, + parent_type: null, + parent_id: null, + }); + }, + setCategoryFilter: function(category_id) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, + parent_type: 'category', + parent_id: category_id, + }); + }, + setFeedFilter: function(feed_id) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, + parent_type: 'feed', + parent_id: feed_id, + }); + }, + setFilterMiddlePanelAll: function() { + JarrDispatcher.dispatch({ + component: 'middle_panel', + type: MiddlePanelActionTypes.MIDDLE_PANEL_FILTER_ALL, + }); + }, + setFilterMiddlePanelUnread: function() { + JarrDispatcher.dispatch({ + component: 'middle_panel', + type: MiddlePanelActionTypes.MIDDLE_PANEL_FILTER_UNREAD, + }); + }, + setFilterMiddlePanelUnread: function() { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.MIDDLE_PANEL_FILTER_LIKED, + }); + }, +}; + +module.exports = MiddlePanelActions; -- cgit