1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

request actions in frontend

This commit is contained in:
diminator 2015-07-01 19:05:47 +02:00
parent 323a2472b4
commit 4ca2144c0c
15 changed files with 89 additions and 23 deletions

View File

@ -8,23 +8,34 @@ import PieceListFetcher from '../fetchers/piece_list_fetcher';
class PieceListActions { class PieceListActions {
constructor() { constructor() {
this.generateActions( this.generateActions(
'updatePieceList' 'updatePieceList',
'updatePieceListRequestActions'
); );
} }
fetchPieceList(page, pageSize, search, orderBy, orderAsc) { fetchPieceList(page, pageSize, search, orderBy, orderAsc) {
PieceListFetcher return new Promise((resolve, reject) => {
.fetch(page, pageSize, search, orderBy, orderAsc) PieceListFetcher
.then((res) => { .fetch(page, pageSize, search, orderBy, orderAsc)
this.actions.updatePieceList({ .then((res) => {
page, this.actions.updatePieceList({
pageSize, page,
search, pageSize,
orderBy, search,
orderAsc, orderBy,
'pieceList': res.pieces, orderAsc,
'pieceListCount': res.count 'pieceList': res.pieces,
'pieceListCount': res.count
});
resolve();
}); });
});
}
fetchPieceRequestActions() {
PieceListFetcher
.fetchRequestActions()
.then((res) => {
this.actions.updatePieceListRequestActions(res.piece_ids);
}); });
} }

View File

@ -3,6 +3,10 @@
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip';
import requests from '../../utils/requests'; import requests from '../../utils/requests';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
@ -21,6 +25,16 @@ let AccordionListItem = React.createClass({
console.log(event.target); console.log(event.target);
}, },
getGlyphicon(){
if (this.props.content.requestAction){
return (
<OverlayTrigger delay={500} placement="left"
overlay={<Tooltip>You have actions pending in one of your editions</Tooltip>}>
<Glyphicon glyph='bell' />
</OverlayTrigger>);
}
return null;
},
render() { render() {
return ( return (
<div className="row"> <div className="row">
@ -42,6 +56,9 @@ let AccordionListItem = React.createClass({
</div> </div>
</div> </div>
<span style={{'clear': 'both'}}></span> <span style={{'clear': 'both'}}></span>
<div className="request-action-batch">
{this.getGlyphicon()}
</div>
</div> </div>
</div> </div>
{this.props.children} {this.props.children}

View File

@ -139,8 +139,12 @@ let AccordionListItemTableEditions = React.createClass({
), ),
new ColumnModel( new ColumnModel(
(item) => { (item) => {
let content = item.acl;
if (item.request_action){
content = [item.request_action + ' request'];
}
return { return {
'content': item.acl 'content': content
}; }, }; },
'acl', 'acl',
getLangText('Actions'), getLangText('Actions'),

View File

@ -54,10 +54,10 @@ let RequestActionForm = React.createClass({
let buttons = ( let buttons = (
<span> <span>
<span> <span>
<div id="request_accept" onClick={this.handleRequest} className='btn btn-default btn-sm'>ACCEPT</div> <div id="request_accept" onClick={this.handleRequest} className='btn btn-default btn-sm ascribe-margin-1px'>ACCEPT</div>
</span> </span>
<span> <span>
<div id="request_deny" onClick={this.handleRequest} className='btn btn-default btn-sm'>REJECT</div> <div id="request_deny" onClick={this.handleRequest} className='btn btn-danger btn-delete btn-sm ascribe-margin-1px'>REJECT</div>
</span> </span>
</span> </span>
); );

View File

@ -21,7 +21,7 @@ let PieceListToolbar = React.createClass({
}, },
render() { render() {
let searchIcon = <Glyphicon glyph='search' />; let searchIcon = <Glyphicon glyph='search' className="filter-glyph"/>;
return ( return (
<div className={this.props.className}> <div className={this.props.className}>

View File

@ -8,7 +8,7 @@ import MenuItem from 'react-bootstrap/lib/MenuItem';
let PieceListToolbarFilterWidgetFilter = React.createClass({ let PieceListToolbarFilterWidgetFilter = React.createClass({
render() { render() {
let filterIcon = <Glyphicon glyph='filter' />; let filterIcon = <Glyphicon glyph='filter' className="filter-glyph"/>;
return ( return (
<DropdownButton title={filterIcon}> <DropdownButton title={filterIcon}>

View File

@ -9,7 +9,7 @@ let TableItemAclFiltered = React.createClass({
}, },
render() { render() {
var availableAcls = ['consign', 'loan', 'transfer', 'view']; var availableAcls = ['consign', 'loan', 'transfer', 'view', 'consign request', 'unconsign request', 'loan request'];
let filteredAcls = this.props.content.filter((v) => { let filteredAcls = this.props.content.filter((v) => {
return availableAcls.indexOf(v) > -1; return availableAcls.indexOf(v) > -1;

View File

@ -80,6 +80,7 @@ let Header = React.createClass({
render() { render() {
let account = null; let account = null;
let signup = null; let signup = null;
let collection = null;
if (this.state.currentUser.username){ if (this.state.currentUser.username){
account = ( account = (
<DropdownButton eventKey="1" title={this.state.currentUser.username}> <DropdownButton eventKey="1" title={this.state.currentUser.username}>
@ -91,6 +92,7 @@ let Header = React.createClass({
<MenuItem eventKey="4" onClick={this.handleLogout}>{getLangText('Log out')}</MenuItem> <MenuItem eventKey="4" onClick={this.handleLogout}>{getLangText('Log out')}</MenuItem>
</DropdownButton> </DropdownButton>
); );
collection = <NavItemLink to="pieces">COLLECTION</NavItemLink>;
} }
else { else {
account = <NavItemLink to="login">LOGIN</NavItemLink>; account = <NavItemLink to="login">LOGIN</NavItemLink>;
@ -101,11 +103,14 @@ let Header = React.createClass({
<div> <div>
<Navbar <Navbar
brand={ brand={
<Link className="navbar-brand" to="pieces" path="/?page=1"> <Link className="navbar-brand" to="pieces">
{this.getLogo()} {this.getLogo()}
</Link>} </Link>}
toggleNavKey={0}> toggleNavKey={0}>
<CollapsibleNav eventKey={0}> <CollapsibleNav eventKey={0}>
<Nav navbar left>
{collection}
</Nav>
<Nav navbar right> <Nav navbar right>
{account} {account}
{signup} {signup}

View File

@ -33,7 +33,8 @@ let PieceList = React.createClass({
let page = this.props.query.page || 1; let page = this.props.query.page || 1;
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
if (this.state.pieceList.length === 0){ if (this.state.pieceList.length === 0){
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc)
.then(PieceListActions.fetchPieceRequestActions());
} }
}, },

View File

@ -227,7 +227,7 @@ let APISettings = React.createClass({
name={app.name} name={app.name}
label={app.name}> label={app.name}>
<div className="row-same-height"> <div className="row-same-height">
<div className="col-xs-6 col-xs-height col-middle"> <div className="no-padding col-xs-6 col-xs-height col-middle">
{'Bearer ' + app.bearer_token.token} {'Bearer ' + app.bearer_token.token}
</div> </div>
<div className="col-xs-6 col-xs-height"> <div className="col-xs-6 col-xs-height">

View File

@ -33,6 +33,7 @@ let apiUrls = {
'piece_extradata': AppConstants.apiEndpoint + 'pieces/${piece_id}/extradata/', 'piece_extradata': AppConstants.apiEndpoint + 'pieces/${piece_id}/extradata/',
'piece_first_edition_id': AppConstants.apiEndpoint + 'pieces/${piece_id}/edition_index/', 'piece_first_edition_id': AppConstants.apiEndpoint + 'pieces/${piece_id}/edition_index/',
'pieces_list': AppConstants.apiEndpoint + 'pieces/', 'pieces_list': AppConstants.apiEndpoint + 'pieces/',
'pieces_list_request_actions': AppConstants.apiEndpoint + 'pieces/request_actions/',
'user': AppConstants.apiEndpoint + 'users/', 'user': AppConstants.apiEndpoint + 'users/',
'users_login': AppConstants.apiEndpoint + 'users/login/', 'users_login': AppConstants.apiEndpoint + 'users/login/',
'users_logout': AppConstants.apiEndpoint + 'users/logout/', 'users_logout': AppConstants.apiEndpoint + 'users/logout/',

View File

@ -12,6 +12,10 @@ let PieceListFetcher = {
fetch(page, pageSize, search, orderBy, orderAsc) { fetch(page, pageSize, search, orderBy, orderAsc) {
let ordering = generateOrderingQueryParams(orderBy, orderAsc); let ordering = generateOrderingQueryParams(orderBy, orderAsc);
return requests.get('pieces_list', { page, pageSize, search, ordering }); return requests.get('pieces_list', { page, pageSize, search, ordering });
},
fetchRequestActions() {
return requests.get('pieces_list_request_actions');
} }
}; };

View File

@ -85,6 +85,11 @@ class PieceListStore {
this.pieceList = pieceList; this.pieceList = pieceList;
} }
onUpdatePieceListRequestActions(requestActions) {
this.pieceList.forEach((piece) => {
piece.requestAction = requestActions.indexOf(piece.id) > -1;
});
}
} }
export default alt.createStore(PieceListStore, 'PieceListStore'); export default alt.createStore(PieceListStore, 'PieceListStore');

View File

@ -45,6 +45,9 @@ $ascribe-accordion-list-font: 'Source Sans Pro';
font-size: 1.1em; font-size: 1.1em;
margin: .2em 0 0 0; margin: .2em 0 0 0;
} }
a {
color: #666;
}
} }
} }
@ -86,4 +89,13 @@ span.ascribe-accordion-list-table-toggle {
font-size:.85em; font-size:.85em;
text-align: center; text-align: center;
} }
}
.request-action-batch {
position: absolute;
top: 0px;
right: 0px;
color: #666;
font-size: 1.2em;
padding: 0.3em;
} }

View File

@ -29,6 +29,10 @@ body {
border-radius: 0; border-radius: 0;
} }
html {
overflow-y: scroll;
}
.hidden { .hidden {
display: none; display: none;
} }
@ -92,7 +96,9 @@ body {
vertical-align: middle; vertical-align: middle;
float: none; float: none;
} }
.filter-glyph{
color: white;
}
.no-margin { .no-margin {
margin-right: 0; margin-right: 0;
margin-left: 0; margin-left: 0;
@ -250,7 +256,7 @@ body {
vertical-align: bottom; vertical-align: bottom;
} }
.ascribe-button-list button { .ascribe-button-list button, .ascribe-margin-1px {
margin-right: 1px; margin-right: 1px;
margin-top: 1px; margin-top: 1px;
} }