From df95e75025785a6b35c52f2b9fec4182395b822b Mon Sep 17 00:00:00 2001 From: vrde Date: Wed, 27 May 2015 17:34:15 +0200 Subject: [PATCH 1/7] WIP --- js/components/ascribe_media/image_viewer.js | 25 -------- .../ascribe_media/resource_viewer.js | 40 +++++++++++++ .../ascribe_table/table_item_subtable.js | 2 +- js/components/edition.js | 11 +++- js/mixins/inject_in_head_mixin.js | 57 +++++++++++++++++++ 5 files changed, 106 insertions(+), 29 deletions(-) delete mode 100644 js/components/ascribe_media/image_viewer.js create mode 100644 js/components/ascribe_media/resource_viewer.js create mode 100644 js/mixins/inject_in_head_mixin.js diff --git a/js/components/ascribe_media/image_viewer.js b/js/components/ascribe_media/image_viewer.js deleted file mode 100644 index fdbd0342..00000000 --- a/js/components/ascribe_media/image_viewer.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -/** - * This is the component that implements display-specific functionality - */ -let ImageViewer = React.createClass({ - propTypes: { - thumbnail: React.PropTypes.string.isRequired - }, - - render() { - let thumbnail = ; - let aligner = ; - return ( -
-
- {aligner} - {thumbnail} -
-
- ); - } -}); - -export default ImageViewer; \ No newline at end of file diff --git a/js/components/ascribe_media/resource_viewer.js b/js/components/ascribe_media/resource_viewer.js new file mode 100644 index 00000000..4519bcb7 --- /dev/null +++ b/js/components/ascribe_media/resource_viewer.js @@ -0,0 +1,40 @@ +import React from 'react'; +import InjectInHeadMixin from '../../mixins/inject_in_head_mixin'; + +/** + * This is the component that implements display-specific functionality. + * + * ResourceViewer handles the following mimetypes: + * - image + * - video + * - audio + * - pdf + * - other + */ + +let resourceMap = { + 'image': 1 +} + +let ResourceViewer = React.createClass({ + propTypes: { + thumbnail: React.PropTypes.string.isRequired, + mimetype: React.PropTypes.oneOf(['image', 'video', 'audio', 'pdf', 'other']).isRequired + }, + + mixins: [InjectInHeadMixin], + + componentDidMount() { + this.inject('http://antani.com'); + }, + + render() { + return ( +
+ resourceviewer {this.props.thumbnail} {this.props.mimetype} +
+ ); + } +}); + +export default ResourceViewer; diff --git a/js/components/ascribe_table/table_item_subtable.js b/js/components/ascribe_table/table_item_subtable.js index e9bd05f2..c8f4c498 100644 --- a/js/components/ascribe_table/table_item_subtable.js +++ b/js/components/ascribe_table/table_item_subtable.js @@ -55,7 +55,7 @@ let TableItemSubtable = React.createClass({ let numOfColumns = GeneralUtils.sumNumList(listOfRowValues); if(numOfColumns > 10) { - throw new Error('Bootstrap has only 12 columns to assign. You defined ' + numOfColumns + '. Change this in the columnMap you\'re passing to the table.') + throw new Error('Bootstrap has only 12 columns to assign. You defined ' + numOfColumns + '. Change this in the columnMap you\'re passing to the table.'); } else { return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i]; } diff --git a/js/components/edition.js b/js/components/edition.js index 336bacff..7bb3f221 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -1,5 +1,5 @@ import React from 'react'; -import ImageViewer from './ascribe_media/image_viewer'; +import ResourceViewer from './ascribe_media/resource_viewer'; /** * This is the component that implements display-specific functionality @@ -10,10 +10,15 @@ let Edition = React.createClass({ //}, render() { + let thumbnail = this.props.edition.thumbnail; + let mimetype = this.props.edition.digital_work.mime; + return (
- +
@@ -103,4 +108,4 @@ let EditionDetails = React.createClass({ }); -export default Edition; \ No newline at end of file +export default Edition; diff --git a/js/mixins/inject_in_head_mixin.js b/js/mixins/inject_in_head_mixin.js new file mode 100644 index 00000000..0c83be16 --- /dev/null +++ b/js/mixins/inject_in_head_mixin.js @@ -0,0 +1,57 @@ +let mapAttr = { + link: 'href', + source: 'src' +} + +let mapExt = { + js: 'source', + css: 'link' +} + + +let InjectInHeadMixin = { + /** + * Provide functions to inject ` diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index 48e02d2d..78cc0eeb 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -6,7 +6,8 @@ class EditionListActions { constructor() { this.generateActions( 'updateEditionList', - 'selectEdition' + 'selectEdition', + 'clearAllEditionSelections' ); } diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js index 2432e019..2b3bd5c0 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js @@ -49,7 +49,7 @@ let AccordionListItemTableEditions = React.createClass({ new TableColumnContentModel((item) => { return { 'editionId': item.id, 'pieceId': this.props.parentId, 'selectItem': this.selectItem, 'selected': item.selected }}, '', '', TableItemCheckbox, 1, false), new TableColumnContentModel((item) => { return { 'content': item.edition_number }}, 'num_editions', 'Nr', TableItemText, 1, false), new TableColumnContentModel((item) => { return { 'content': item.bitcoin_id }}, 'bitcoin_id', 'Bitcoin Address', TableItemText, 5, false), - new TableColumnContentModel((item) => { return { 'content': item.acl }}, 'acl', 'Actions', TableItemAclFiltered, 5, false) + new TableColumnContentModel((item) => { return { 'content': item.acl }}, 'acl', 'Actions', TableItemAclFiltered, 4, false) ]; return ( diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js index 4840b27a..f7b04cc6 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js @@ -1,11 +1,16 @@ import React from 'react'; import EditionListStore from '../../stores/edition_list_store'; +import EditionListActions from '../../actions/edition_list_actions'; import AclButton from '../acl_button'; import PieceListToolbarSelectedEditionsWidget from './piece_list_toolbar_selected_editions_widget'; let PieceListToolbar = React.createClass({ + propTypes: { + className: React.PropTypes.string + }, + getInitialState() { return EditionListStore.getState(); }, @@ -66,25 +71,46 @@ let PieceListToolbar = React.createClass({ return availableAcls; }, + clearAllSelections() { + EditionListActions.clearAllEditionSelections(); + }, + render() { let availableAcls = this.getAvailableAcls(); - return ( -
-
-
- -
-
- - - - + if(availableAcls.length > 0) { + return ( +
+
+
+

+
+
+ +           + clear all +
+
+

+
+
+ + + + +
+
+
-
- ); + ); + } else { + return null; + } + } }); diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 3f36cfe2..9580ffb1 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -50,6 +50,7 @@ let PieceList = React.createClass({ return (
+ {this.state.pieceList.map((item, i) => { - return ( { + this.editionList[pieceId] + .forEach((edition) => { + try { + delete edition.selected; + } catch(err) { + //just ignore + } + }); + }); + } }; export default alt.createStore(EditionListStore); \ No newline at end of file diff --git a/sass/ascribe-piece-list-toolbar.scss b/sass/ascribe-piece-list-toolbar.scss new file mode 100644 index 00000000..6093aed9 --- /dev/null +++ b/sass/ascribe-piece-list-toolbar.scss @@ -0,0 +1,20 @@ +.ascribe-piece-list-toolbar { + position: fixed; + top:0; + width:1170px; + height:6em; + background-color: #FAFAFA; + + border-left: 0.1em solid #E0E0E0; + border-right: 0.1em solid #E0E0E0; + border-top: 0.1em solid #E0E0E0; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + border-bottom: 0.2em solid #E0E0E0; + z-index:9999; +} + +.piece-list-toolbar-clear-all { + text-decoration: underline; + cursor:pointer; +} \ No newline at end of file diff --git a/sass/main.scss b/sass/main.scss index 419da031..471a6124 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -6,6 +6,7 @@ @import './ascribe-fonts/style'; @import './ascribe-fonts/ascribe-fonts'; @import 'ascribe-accordion_list'; +@import 'ascribe-piece-list-toolbar'; .hidden { display: none; @@ -14,6 +15,12 @@ .navbar-default { border-left:0; border-right:0; + margin-bottom: 3em; +} + +.clear-margins-and-paddings { + padding-left:0; + padding-right:0; } .ascribe-color { @@ -68,6 +75,9 @@ .ascribe-table-item-column > * { display: table-cell; vertical-align: middle; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } .ascribe-table-item-selected { @@ -78,10 +88,6 @@ cursor: default; } -.piece-list-toolbar { - height:3em; -} - .no-margin { margin-right: 0; margin-left: 0;