1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00
This commit is contained in:
diminator 2015-07-13 23:57:16 +02:00
parent a985fb855e
commit 9a7bf46675
10 changed files with 38 additions and 31 deletions

View File

@ -83,7 +83,7 @@ let AccordionListItem = React.createClass({
render() {
let linkData;
if(this.props.content.num_editions < 1) {
if(this.props.content.num_editions < 1 || !this.props.content.first_edition) {
linkData = {
to: 'piece',
params: {
@ -94,7 +94,7 @@ let AccordionListItem = React.createClass({
linkData = {
to: 'edition',
params: {
editionId: this.props.content.first_edition ? this.props.content.first_edition.bitcoin_id : 0
editionId: this.props.content.first_edition.bitcoin_id
}
};
}

View File

@ -73,6 +73,7 @@ let AccordionListItemEditionWidget = React.createClass({
let numEditions = piece.num_editions;
if(numEditions <= 0) {
if (piece.acl.acl_editions){
return (
<CreateEditionsButton
label={getLangText('Create editions')}
@ -81,23 +82,19 @@ let AccordionListItemEditionWidget = React.createClass({
toggleCreateEditionsDialog={this.props.toggleCreateEditionsDialog}
onPollingSuccess={this.props.onPollingSuccess}/>
);
} else if(numEditions === 1) {
let editionMapping = piece && piece.first_edition ? piece.first_edition.edition_number + '/' + piece.num_editions : '';
}
else {
return null;
}
} else {
let editionMapping = piece && piece.first_edition ? piece.first_edition.num_editions_available + '/' + piece.num_editions : '';
return (
<button
onClick={this.toggleTable}
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
{editionMapping + ' ' + getLangText('Edition')} {this.getGlyphicon()}
</button>
);
}
else {
return (
<button
onClick={this.toggleTable}
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
{numEditions + ' ' + getLangText('Editions')} {this.getGlyphicon()}
{editionMapping + ' ' + getLangText('Editions')} {this.getGlyphicon()}
</button>
);
}

View File

@ -67,7 +67,7 @@ let CreateEditionsButton = React.createClass({
let availableAcls = getAvailableAcls(piece);
if (availableAcls.editions || piece.num_editions > 0){
if (!piece.acl.acl_editions || piece.num_editions > 0){
return null;
}

View File

@ -45,7 +45,7 @@ let DeleteButton = React.createClass({
content = <EditionDeleteForm editions={ this.props.editions }/>;
btnDelete = <Button bsStyle="danger" className="btn-delete" bsSize="small">{getLangText('DELETE')}</Button>;
}
else if (availableAcls.acl_unshare){
else if (availableAcls.acl_unshare || (this.props.editions.constructor !== Array && this.props.editions.acl.acl_unshare)){
content = <EditionRemoveFromCollectionForm editions={ this.props.editions }/>;
btnDelete = <Button bsStyle="danger" className="btn-delete" bsSize="small">{getLangText('REMOVE FROM COLLECTION')}</Button>;
}

View File

@ -113,7 +113,8 @@ let Piece = React.createClass({
<AclButtonList
className="text-center ascribe-button-list"
availableAcls={this.props.piece.acl}
editions={this.props.piece}>
editions={this.props.piece}
handleSuccess={this.props.loadPiece}>
<CreateEditionsButton
label={getLangText('CREATE EDITIONS')}
className="btn-sm"

View File

@ -24,8 +24,9 @@ let EditionDeleteForm = React.createClass({
<p>{getLangText('Are you sure you would like to permanently delete this edition')}&#63;</p>
<p>{getLangText('This is an irrevocable action%s', '.')}</p>
<div className="modal-footer">
<button type="submit" className="btn btn-ascribe-inv" onClick={this.submit}>{getLangText('YES, DELETE')}</button>
<button className="btn btn-ascribe" onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</button>
<button type="submit" className="btn btn-danger btn-delete btn-sm ascribe-margin-1px" onClick={this.submit}>{getLangText('YES, DELETE')}</button>
<button className="btn btn-default btn-sm ascribe-margin-1px" style={{marginLeft: '0'}}
onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</button>
</div>
</div>
);

View File

@ -2,7 +2,7 @@
import React from 'react';
import { getLangText } from '../../utils/lang_utils.js'
import { getLangText } from '../../utils/lang_utils.js';
import requests from '../../utils/requests';
import apiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
@ -12,7 +12,12 @@ let EditionRemoveFromCollectionForm = React.createClass({
mixins: [FormMixin],
url() {
if (this.props.editions.constructor === Array) {
return requests.prepareUrl(apiUrls.edition_remove_from_collection, {edition_id: this.getBitcoinIds().join()});
}
else {
return requests.prepareUrl(apiUrls.piece_remove_from_collection, {piece_id: this.editions.piece_id});
}
},
httpVerb(){
return 'delete';

View File

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

View File

@ -8,7 +8,9 @@ function intersectAcls(a, b) {
export function getAvailableAcls(editions) {
let availableAcls = [];
if (editions.constructor !== Array){
return [];
}
// if you copy a javascript array of objects using slice, then
// the object reference is still there.
// Therefore we need to do this ugly copying