diff --git a/.travis.yml b/.travis.yml index caca44181..ca7e251f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,14 @@ before_script: - "if [ \"$PHPCS_TEST\" = \"1\" ]; then pyrus install pear/PHP_CodeSniffer; fi" - phpenv rehash - phpenv config-rm xdebug.ini + - echo 'always_populate_raw_post_data = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss - cd ~/builds/ss + - "if [ \"$BEHAT_TEST\" = \"1\" ]; then mkdir asset-admin/artifacts; fi" - "if [ \"$BEHAT_TEST\" = \"1\" ]; then sh -e /etc/init.d/xvfb start; sleep 3; fi" - - "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/selenium-server-standalone > selenium.log 2>&1 &); fi" - - "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/serve --bootstrap-file cms/tests/behat/serve-bootstrap.php &> serve.log &); fi" + - "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/selenium-server-standalone > asset-admin/artifacts/selenium.log 2>&1 &); fi" + - "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/serve --bootstrap-file cms/tests/behat/serve-bootstrap.php &> asset-admin/artifacts/serve.log &); fi" script: - "if [ \"$PHPUNIT_TEST\" = \"1\" ]; then vendor/bin/phpunit asset-admin/tests/php; fi" @@ -44,10 +46,10 @@ script: - "if [ \"$NPM_TEST\" = \"1\" ]; then (cd asset-admin && nvm use 4 && npm run test); fi" - "if [ \"$NPM_TEST\" = \"1\" ]; then (cd asset-admin && nvm use 4 && npm run lint); fi" - "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @asset-admin --config=./asset-admin/behat.yml; fi" - - "if [ \"$PHPCS_TEST\" = \"1\" ]; then phpcs --standard=asset-admin/tests/phpcs/ruleset.xml asset-admin/code/ asset-admin/tests/; fi" + - "if [ \"$PHPCS_TEST\" = \"1\" ]; then phpcs --standard=asset-admin/tests/phpcs/ruleset.xml asset-admin/code/ asset-admin/tests/; fi" after_failure: - - php ./framework/tests/behat/travis-upload-artifacts.php --if-env BEHAT_TEST,ARTIFACTS_BUCKET,ARTIFACTS_KEY,ARTIFACTS_SECRET --target-path $TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/ + - php ./framework/tests/behat/travis-upload-artifacts.php --if-env BEHAT_TEST,ARTIFACTS_BUCKET,ARTIFACTS_KEY,ARTIFACTS_SECRET --target-path $TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/ --artifacts-path ./asset-admin/artifacts/ notifications: slack: silverstripeltd:Cls1xnypKBLFhv0YIRtNLzlQ diff --git a/_config/config.yml b/_config/config.yml index 278a2b21b..2e8c3976e 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -9,3 +9,19 @@ SilverStripe\Assets\File: SilverStripe\Admin\LeftAndMain: extensions: - SilverStripe\AssetAdmin\Controller\AssetAdminFieldsExtension +SilverStripe\GraphQL: + schema: + types: + DataObjectInterface: 'SilverStripe\GraphQL\DataObjectInterfaceTypeCreator' + File: 'SilverStripe\AssetAdmin\GraphQL\FileTypeCreator' + FileInterface: 'SilverStripe\AssetAdmin\GraphQL\FileInterfaceTypeCreator' + FileInput: 'SilverStripe\AssetAdmin\GraphQL\FileInputTypeCreator' + Folder: 'SilverStripe\AssetAdmin\GraphQL\FolderTypeCreator' + FolderInput: 'SilverStripe\AssetAdmin\GraphQL\FolderInputTypeCreator' + queries: + readFiles: 'SilverStripe\AssetAdmin\GraphQL\ReadFileQueryCreator' + mutations: + createFile: 'SilverStripe\AssetAdmin\GraphQL\CreateFileMutationCreator' + updateFile: 'SilverStripe\AssetAdmin\GraphQL\UpdateFileMutationCreator' + deleteFile: 'SilverStripe\AssetAdmin\GraphQL\DeleteFileMutationCreator' + createFolder: 'SilverStripe\AssetAdmin\GraphQL\CreateFolderMutationCreator' diff --git a/behat.yml b/behat.yml index e7d2dd275..baaf54f27 100644 --- a/behat.yml +++ b/behat.yml @@ -12,6 +12,7 @@ default: SilverStripe\BehatExtension\Extension: framework_path: ../framework bootstrap_file: "cms/tests/behat/serve-bootstrap.php" + screenshot_path: %behat.paths.base%/artifacts/screenshots Behat\MinkExtension\Extension: # Adjust this to your local environment base_url: http://localhost:8080/ diff --git a/client/dist/images/folder_icon_large.png b/client/dist/images/folder_icon_large.png new file mode 100644 index 000000000..545505b77 Binary files /dev/null and b/client/dist/images/folder_icon_large.png differ diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index 0abb586bc..2b737805d 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -2,7 +2,7 @@ var o=n[r]={exports:{},id:r,loaded:!1} return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={} return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict" -n(1),n(277),n(301),n(303)},function(e,t,n){(function(t){e.exports=t.InsertMediaModal=n(2)}).call(t,function(){return this}())},function(e,t,n){"use strict" +n(1),n(380),n(404),n(406)},function(e,t,n){(function(t){e.exports=t.InsertMediaModal=n(2)}).call(t,function(){return this}())},function(e,t,n){"use strict" function r(e){if(e&&e.__esModule)return e var t={} if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]) @@ -10,124 +10,140 @@ return t["default"]=e,t}function o(e){return e&&e.__esModule?e:{"default":e}}fun return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t) -e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n=e.config.sections[S],r=t.fileAttributes?t.fileAttributes.ID:null,o=e.config.sections[S],i=r&&o.form.fileInsertForm.schemaUrl+"/"+r +e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n=e.config.sections[w],r=t.fileAttributes?t.fileAttributes.ID:null,o=e.config.sections[w],i=r&&o.form.fileInsertForm.schemaUrl+"/"+r -return{sectionConfig:n,schemaUrl:i}}function u(e){return{actions:{schema:(0,m.bindActionCreators)(_,e)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.InsertMediaModal=void 0 +return{sectionConfig:n,schemaUrl:i}}function u(e){return{actions:{schema:(0,m.bindActionCreators)(E,e)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.InsertMediaModal=void 0 var p=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0 try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(l){o=!0,i=l}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){ if(Array.isArray(t))return t if(Symbol.iterator in Object(t))return e(t,n) -throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=Object.assign||function(e){for(var t=1;t-1}},{key:"itemIsHighlighted",value:function M(e){return this.props.fileId===e}},{key:"handleOpenFolder",value:function H(e,t){ -e.preventDefault(),this.props.onOpenFolder(t.id)}},{key:"handleOpenFile",value:function B(e,t){e.preventDefault(),null!==t.created&&this.props.onOpenFile(t.id,t)}},{key:"handleSelect",value:function G(e,t){ -this.props.selectedFiles.indexOf(t.id)===-1?this.props.actions.gallery.selectFiles([t.id]):this.props.actions.gallery.deselectFiles([t.id])}},{key:"handleBackClick",value:function q(e){e.preventDefault(), -this.props.onOpenFolder(this.props.folder.parentID)}},{key:"handleViewChange",value:function V(e){var t=e.currentTarget.value -this.props.onViewChange(t)}},{key:"renderSort",value:function W(){var e=this -return"tile"!==this.props.view?null:v["default"].createElement("div",{className:"gallery__sort fieldholder-small"},v["default"].createElement("select",{className:"dropdown no-change-track no-chzn",tabIndex:"0", -style:{width:"160px"},defaultValue:this.props.sort},z.map(function(t,n){return v["default"].createElement("option",{key:n,onClick:e.handleSelectSort,"data-field":t.field,"data-direction":t.direction,value:t.field+","+t.direction +this.props.onOpenFile(n.id)}}},{key:"handleFailedUpload",value:function A(e,t){this.props.actions.queuedFiles.failUpload(e._queuedId,t)}},{key:"promptFolderName",value:function D(){return prompt(C["default"]._t("AssetAdmin.PROMPTFOLDERNAME")) + +}},{key:"itemIsSelected",value:function R(e){return this.props.selectedFiles.indexOf(e)>-1}},{key:"itemIsHighlighted",value:function U(e){return this.props.fileId===e}},{key:"handleOpenFolder",value:function M(e,t){ +e.preventDefault(),this.props.onOpenFolder(t.id)}},{key:"handleOpenFile",value:function q(e,t){e.preventDefault(),null!==t.created&&this.props.onOpenFile(t.id,t)}},{key:"handleSelect",value:function B(e,t){ +this.props.selectedFiles.indexOf(t.id)===-1?this.props.actions.gallery.selectFiles([t.id]):this.props.actions.gallery.deselectFiles([t.id])}},{key:"handleBackClick",value:function H(e){e.preventDefault(), +this.props.onOpenFolder(this.props.folder.parentId)}},{key:"handleViewChange",value:function G(e){var t=e.currentTarget.value +this.props.onViewChange(t)}},{key:"renderSort",value:function V(){var e=this +return"tile"!==this.props.view?null:E["default"].createElement("div",{className:"gallery__sort fieldholder-small"},E["default"].createElement("select",{className:"dropdown no-change-track no-chzn",tabIndex:"0", +style:{width:"160px"},defaultValue:this.props.sort},$.map(function(t,n){return E["default"].createElement("option",{key:n,onClick:e.handleSelectSort,"data-field":t.field,"data-direction":t.direction,value:t.field+","+t.direction },t.label)})))}},{key:"renderToolbar",value:function Q(){var e=this.props.folder.canEdit -return v["default"].createElement("div",{className:"toolbar--content toolbar--space-save"},v["default"].createElement("div",{className:"fill-width"},v["default"].createElement("div",{className:"flexbox-area-grow" -},this.renderBackButton(),v["default"].createElement("button",{id:"upload-button",className:"btn btn-secondary font-icon-upload btn--icon-xl",type:"button",disabled:!e},v["default"].createElement("span",{ -className:"btn__text"},g["default"]._t("AssetAdmin.DROPZONE_UPLOAD"))),v["default"].createElement("button",{id:"add-folder-button",className:"btn btn-secondary font-icon-folder-add btn--icon-xl",type:"button", -onClick:this.handleCreateFolder,disabled:!e},v["default"].createElement("span",{className:"btn__text"},g["default"]._t("AssetAdmin.ADD_FOLDER_BUTTON")))),v["default"].createElement("div",{className:"gallery__state-buttons" -},this.renderSort(),v["default"].createElement("div",{className:"btn-group",role:"group","aria-label":"View mode"},this.renderViewChangeButtons()))))}},{key:"renderViewChangeButtons",value:function K(){ +return E["default"].createElement("div",{className:"toolbar--content toolbar--space-save"},E["default"].createElement("div",{className:"fill-width"},E["default"].createElement("div",{className:"flexbox-area-grow" +},this.renderBackButton(),E["default"].createElement("button",{id:"upload-button",className:"btn btn-secondary font-icon-upload btn--icon-xl",type:"button",disabled:!e},E["default"].createElement("span",{ +className:"btn__text"},C["default"]._t("AssetAdmin.DROPZONE_UPLOAD"))),E["default"].createElement("button",{id:"add-folder-button",className:"btn btn-secondary font-icon-folder-add btn--icon-xl",type:"button", +onClick:this.handleCreateFolder,disabled:!e},E["default"].createElement("span",{className:"btn__text"},C["default"]._t("AssetAdmin.ADD_FOLDER_BUTTON")))),E["default"].createElement("div",{className:"gallery__state-buttons" +},this.renderSort(),E["default"].createElement("div",{className:"btn-group",role:"group","aria-label":"View mode"},this.renderViewChangeButtons()))))}},{key:"renderViewChangeButtons",value:function W(){ var e=this,t=["tile","table"] return t.map(function(t,n){var r="table"===t?"list":"thumbnails",o=["gallery__view-change-button","btn btn-secondary","btn--icon-sm","btn--no-text"] -return t===e.props.view?null:(o.push("font-icon-"+r),v["default"].createElement("button",{id:"button-view-"+t,key:n,className:o.join(" "),type:"button",onClick:e.handleViewChange,value:t}))})}},{key:"renderBackButton", -value:function $(){var e=["btn","btn-secondary","btn--no-text","font-icon-level-up","btn--icon-large","gallery__back"].join(" ") -return null!==this.props.folder.parentID?v["default"].createElement("button",{className:e,onClick:this.handleBackClick,ref:"backButton"}):null}},{key:"renderBulkActions",value:function Z(){var e=this,t=function i(t){ -var n=t.map(function(e){return e.id}) -e.props.actions.gallery.deleteItems(e.props.deleteApi,n)},n=function s(t){e.props.onOpenFile(t[0].id)},r=U["default"].BULK_ACTIONS.map(function(e){return"delete"!==e.value||e.callback?"edit"!==e.value||e.callback?e:d({},e,{ -callback:n}):d({},e,{callback:t})}),o=this.props.selectedFiles.map(function(t){return e.props.files.find(function(e){return t===e.id})}) -return o.length>0&&"admin"===this.props.type?v["default"].createElement(w["default"],{transitionName:"bulk-actions",transitionEnterTimeout:U["default"].CSS_TRANSITION_TIME,transitionLeaveTimeout:U["default"].CSS_TRANSITION_TIME -},v["default"].createElement(A["default"],{actions:r,items:o,key:o.length>0})):null}},{key:"renderNoItemsNotice",value:function Y(){return 0!==this.props.files.length||this.props.loading?null:v["default"].createElement("p",{ -className:"gallery__no-item-notice"},g["default"]._t("AssetAdmin.NOITEMSFOUND"))}},{key:"renderGalleryView",value:function X(){var e=this,t="table"===this.props.view?N["default"]:D["default"],n=this.props.files.map(function(t){ -return d({},t,{selected:e.itemIsSelected(t.id),highlighted:e.itemIsHighlighted(t.id)})}),r=this.props.queuedFiles.items.map(function(e){return d({},e,{uploading:!0})}),o=[].concat(i(r),i(n)),s=this.props,a=s.type,l=s.loading,u=s.page,p=s.count,c=s.limit,f=s.sort,h={ -selectableItems:"admin"===a,files:o,loading:l,page:u,count:p,limit:c,sort:f,onSort:this.handleSort,onSetPage:this.handleSetPage,onOpenFile:this.handleOpenFile,onOpenFolder:this.handleOpenFolder,onSelect:this.handleSelect, -onCancelUpload:this.handleCancelUpload,onRemoveErroredUpload:this.handleRemoveErroredUpload,renderNoItemsNotice:this.renderNoItemsNotice} -return v["default"].createElement(t,h)}},{key:"render",value:function J(){if(!this.props.folder)return this.props.errorMessage?v["default"].createElement("div",{className:"gallery__error"},v["default"].createElement("div",{ -className:"gallery__error-message"},v["default"].createElement("h3",null,this.props.errorMessage&&g["default"]._t("AssetAdmin.DROPZONE_RESPONSE_ERROR","Server responded with an error.")),v["default"].createElement("p",null,this.props.errorMessage))):null - - -var e={height:U["default"].THUMBNAIL_HEIGHT,width:U["default"].THUMBNAIL_WIDTH},t={url:this.props.createFileApiUrl,method:this.props.createFileApiMethod,paramName:"Upload",clickable:"#upload-button"},n=this.props.securityId,r=this.props.folder.canEdit,o=["panel","panel--padded","panel--scrollable","gallery__main"] - - -return"insert"===this.props.type&&o.push("insert-media-modal__main"),v["default"].createElement("div",{className:"flexbox-area-grow gallery__outer"},this.renderBulkActions(),v["default"].createElement(T["default"],{ -name:"gallery-container",canUpload:r,handleAddedFile:this.handleAddedFile,handleError:this.handleFailedUpload,handleSuccess:this.handleSuccessfulUpload,handleSending:this.handleSending,handleUploadProgress:this.handleUploadProgress, -preview:e,folderId:this.props.folderId,options:t,securityID:n,uploadButton:!1},v["default"].createElement("div",{className:o.join(" ")},this.renderToolbar(),this.renderGalleryView())))}}]),t}(y.Component),G={ -page:0,limit:15,sort:z[0].field+","+z[0].direction},q={loading:y.PropTypes.bool,sort:y.PropTypes.string,files:y.PropTypes.arrayOf(y.PropTypes.shape({id:y.PropTypes.number,parent:y.PropTypes.shape({id:y.PropTypes.number -})})).isRequired,count:y.PropTypes.number,page:y.PropTypes.number,limit:y.PropTypes.number,onOpenFile:y.PropTypes.func.isRequired,onOpenFolder:y.PropTypes.func.isRequired,onSort:y.PropTypes.func.isRequired, -onSetPage:y.PropTypes.func.isRequired},V=d({},G,{selectableItems:!1}),W=d({},q,{selectableItems:y.PropTypes.bool,onSelect:y.PropTypes.func,onCancelUpload:y.PropTypes.func,onRemoveErroredUpload:y.PropTypes.func, -renderNoItemsNotice:y.PropTypes.func.isRequired}) -B.defaultProps=d({},G,{type:"admin",view:"tile"}),B.propTypes=d({},q,{type:y.PropTypes.oneOf(["insert","select","admin"]),view:y.PropTypes.oneOf(["tile","table"]),dialog:y.PropTypes.bool,fileId:y.PropTypes.number, -folderId:y.PropTypes.number.isRequired,folder:y.PropTypes.shape({id:y.PropTypes.number,parentID:y.PropTypes.number,canView:y.PropTypes.bool,canEdit:y.PropTypes.bool}),queuedFiles:y.PropTypes.shape({items:y.PropTypes.array.isRequired -}),selectedFiles:y.PropTypes.arrayOf(y.PropTypes.number),errorMessage:y.PropTypes.string,actions:y.PropTypes.object.isRequired,securityId:y.PropTypes.string,onViewChange:y.PropTypes.func.isRequired,createFileApiUrl:y.PropTypes.string, -createFileApiMethod:y.PropTypes.string,createFolderApi:y.PropTypes.func,readFolderApi:y.PropTypes.func,deleteApi:y.PropTypes.func}),t.Gallery=B,t.sorters=z,t.galleryViewPropTypes=W,t.galleryViewDefaultProps=V, -t["default"]=(0,P.connect)(u,p)(B)},function(e,t){e.exports=jQuery},function(e,t){e.exports=ReactDom},function(e,t){e.exports=ReactAddonsTestUtils},function(e,t){e.exports=ReactAddonsCssTransitionGroup +return t===e.props.view?null:(o.push("font-icon-"+r),E["default"].createElement("button",{id:"button-view-"+t,key:n,className:o.join(" "),type:"button",onClick:e.handleViewChange,value:t}))})}},{key:"renderBackButton", +value:function K(){var e=["btn","btn-secondary","btn--no-text","font-icon-level-up","btn--icon-large","gallery__back"].join(" ") +return null!==this.props.folder.parentId?E["default"].createElement("button",{className:e,onClick:this.handleBackClick,ref:"backButton"}):null}},{key:"renderBulkActions",value:function Y(){var e=this,t=function a(t){ +t.forEach(function(t){return e.props.onDelete(t.id)})},n=function l(t){e.props.onOpenFile(t[0].id)},r=z["default"].BULK_ACTIONS.map(function(e){return"delete"!==e.value||e.callback?"edit"!==e.value||e.callback?e:d({},e,{ +callback:n}):d({},e,{callback:t})}),o=[].concat(s(this.props.files),s(this.props.queuedFiles.items)),i=this.props.selectedFiles.map(function(e){return o.find(function(t){return t&&e===t.id})}) +return i.length>0&&"admin"===this.props.type?E["default"].createElement(I["default"],{transitionName:"bulk-actions",transitionEnterTimeout:z["default"].CSS_TRANSITION_TIME,transitionLeaveTimeout:z["default"].CSS_TRANSITION_TIME +},E["default"].createElement(N["default"],{actions:r,items:i,key:i.length>0})):null}},{key:"renderGalleryView",value:function Z(){var e=this,t="table"===this.props.view?L["default"]:j["default"],n=this.props.queuedFiles.items.filter(function(t){ +return!t.id||!e.props.files.find(function(e){return e.id===t.id})}).map(function(e){return d({},e,{uploading:!(e.id>0)})}),r=[].concat(s(n),s(this.props.files)).map(function(t){return d({},t||{},{selected:e.itemIsSelected(t.id), +highlighted:e.itemIsHighlighted(t.id)})}),o=this.props,i=o.type,a=o.loading,l=o.page,u=o.totalCount,p=o.limit,c=o.sort,f={selectableItems:"admin"===i,files:r,loading:a,page:l,totalCount:u,limit:p,sort:c, +onSort:this.handleSort,onSetPage:this.handleSetPage,onOpenFile:this.handleOpenFile,onOpenFolder:this.handleOpenFolder,onSelect:this.handleSelect,onCancelUpload:this.handleCancelUpload,onRemoveErroredUpload:this.handleRemoveErroredUpload +} +return E["default"].createElement(t,f)}},{key:"render",value:function X(){if(!this.props.folder)return this.props.errorMessage?E["default"].createElement("div",{className:"gallery__error"},E["default"].createElement("div",{ +className:"gallery__error-message"},E["default"].createElement("h3",null,this.props.errorMessage&&C["default"]._t("AssetAdmin.DROPZONE_RESPONSE_ERROR","Server responded with an error.")),E["default"].createElement("p",null,this.props.errorMessage))):null -},function(e,t,n){"use strict" + +var e={height:z["default"].THUMBNAIL_HEIGHT,width:z["default"].THUMBNAIL_WIDTH},t={url:this.props.createFileApiUrl,method:this.props.createFileApiMethod,paramName:"Upload",clickable:"#upload-button"},n=this.props.securityId,r=this.props.folder.canEdit,o=["panel","panel--padded","panel--scrollable","gallery__main"] + + +return"insert"===this.props.type&&o.push("insert-media-modal__main"),E["default"].createElement("div",{className:"flexbox-area-grow gallery__outer"},this.renderBulkActions(),E["default"].createElement(k["default"],{ +name:"gallery-container",canUpload:r,handleAddedFile:this.handleAddedFile,handleError:this.handleFailedUpload,handleSuccess:this.handleSuccessfulUpload,handleSending:this.handleSending,handleUploadProgress:this.handleUploadProgress, +preview:e,folderId:this.props.folderId,options:t,securityID:n,uploadButton:!1},E["default"].createElement("div",{className:o.join(" ")},this.renderToolbar(),this.renderGalleryView())))}}]),t}(_.Component),Y={ +page:0,limit:15,sort:$[0].field+","+$[0].direction},Z={loading:_.PropTypes.bool,sort:_.PropTypes.string,files:_.PropTypes.arrayOf(_.PropTypes.shape({id:_.PropTypes.number,parent:_.PropTypes.shape({id:_.PropTypes.number +})})).isRequired,totalCount:_.PropTypes.number,page:_.PropTypes.number,limit:_.PropTypes.number,onOpenFile:_.PropTypes.func.isRequired,onOpenFolder:_.PropTypes.func.isRequired,onSort:_.PropTypes.func.isRequired, +onSetPage:_.PropTypes.func.isRequired},X=d({},Y,{selectableItems:!1}),J=d({},Z,{selectableItems:_.PropTypes.bool,onSelect:_.PropTypes.func,onCancelUpload:_.PropTypes.func,onDelete:E["default"].PropTypes.func, +onRemoveErroredUpload:_.PropTypes.func}) +K.defaultProps=d({},Y,{type:"admin",view:"tile"}),K.propTypes=d({},Z,{client:E["default"].PropTypes.object,mutate:E["default"].PropTypes.func,onUploadSuccess:E["default"].PropTypes.func,onCreateFolderSuccess:E["default"].PropTypes.func, +onDelete:E["default"].PropTypes.func,type:_.PropTypes.oneOf(["insert","select","admin"]),view:_.PropTypes.oneOf(["tile","table"]),dialog:_.PropTypes.bool,fileId:_.PropTypes.number,folderId:_.PropTypes.number.isRequired, +folder:_.PropTypes.shape({id:_.PropTypes.number,parentId:_.PropTypes.number,canView:_.PropTypes.bool,canEdit:_.PropTypes.bool}),queuedFiles:_.PropTypes.shape({items:_.PropTypes.array.isRequired}),selectedFiles:_.PropTypes.arrayOf(_.PropTypes.number), +errorMessage:_.PropTypes.string,actions:_.PropTypes.object,securityId:_.PropTypes.string,onViewChange:_.PropTypes.func.isRequired,createFileApiUrl:_.PropTypes.string,createFileApiMethod:_.PropTypes.string +}),K.fragments={fileInterface:(0,W["default"])(h),file:(0,W["default"])(m)} +var ee=(0,W["default"])(g,K.fragments.fileInterface,K.fragments.file) +t.Gallery=K,t.sorters=$,t.galleryViewPropTypes=J,t.galleryViewDefaultProps=X,t["default"]=(0,O.compose)((0,V.graphql)(ee),function(e){return(0,V.withApollo)(e)},(0,T.connect)(p,c))(K)},function(e,t){e.exports=jQuery + +},function(e,t){e.exports=ReactDom},function(e,t){e.exports=ReactAddonsTestUtils},function(e,t){e.exports=ReactAddonsCssTransitionGroup},function(e,t,n){"use strict" function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called") @@ -267,68 +292,68 @@ e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,wri value:!0}) var a=Object.assign||function(e){for(var t=1;tthis.props.options.maxFiles)return this.dropzone.removeFile(this.dropzone.files[0]),"function"==typeof this.props.handleMaxFilesExceeded&&this.props.handleMaxFilesExceeded(e), Promise.resolve() if("function"==typeof this.props.canFileUpload&&!this.props.canFileUpload(e))return this.dropzone.removeFile(e),Promise.resolve() -if(!this.props.canUpload)return this.dropzone.removeFile(e),Promise.reject(new Error(y["default"]._t("AssetAdmin.DROPZONE_CANNOT_UPLOAD"))) +if(!this.props.canUpload)return this.dropzone.removeFile(e),Promise.reject(new Error(v["default"]._t("AssetAdmin.DROPZONE_CANNOT_UPLOAD"))) e._queuedId=this.generateQueuedId() var n=new Promise(function(n){var r=new FileReader r.onload=function(r){if("image"===t.getFileCategory(e.type)){var o=document.createElement("img") n(t.loadImage(o,r.target.result))}else n({})},r.readAsDataURL(e)}) -return n.then(function(n){var r={dimensions:{height:n.height,width:n.width},category:t.getFileCategory(e.type),filename:e.name,queuedId:e._queuedId,size:e.size,title:t.getFileTitle(e.name),extension:(0, -_.getFileExtension)(e.name),type:e.type,url:n.thumbnailURL} -return t.props.handleAddedFile(r),t.dropzone.processFile(e),r})}},{key:"getFileTitle",value:function F(e){return e.replace(/[.][^.]+$/,"").replace(/-_/," ")}},{key:"loadImage",value:function T(e,t){var n=this +return n.then(function(n){var r={height:n.height,width:n.width,category:t.getFileCategory(e.type),filename:e.name,queuedId:e._queuedId,size:e.size,title:t.getFileTitle(e.name),extension:(0,E.getFileExtension)(e.name), +type:e.type,url:n.thumbnailURL,thumbnail:n.thumbnailURL,smallThumbail:n.thumbnailURL} +return t.props.handleAddedFile(r),t.dropzone.processFile(e),r})}},{key:"getFileTitle",value:function F(e){return e.replace(/[.][^.]+$/,"").replace(/-_/," ")}},{key:"loadImage",value:function I(e,t){var n=this return new Promise(function(r){e.onload=function(){var t=document.createElement("canvas"),o=t.getContext("2d"),i=2*n.props.preview.width,s=2*n.props.preview.height,a=e.naturalWidth/e.naturalHeight e.naturalWidth'+this.options.dictRemoveFile+""),e.previewElement.appendChild(e._removeLink)), r=function(n){return function(r){return r.preventDefault(),r.stopPropagation(),e.status===t.UPLOADING?t.confirm(n.options.dictCancelUploadConfirmation,function(){return n.removeFile(e)}):n.options.dictRemoveFileConfirmation?t.confirm(n.options.dictRemoveFileConfirmation,function(){ return n.removeFile(e)}):n.removeFile(e)}}(this),f=e.previewElement.querySelectorAll("[data-dz-remove]"),h=[],a=0,p=f.length;a=t)&&(r=this.getQueuedFiles(),r.length>0)){if(this.options.uploadMultiple)return this.processFiles(r.slice(0,t-n)) for(;e=L;p=0<=L?++O:--O)i.append(this._getParamName(p),e[p],this._renameFilename(e[p].name)) -return this.submitRequest(_,i,e)},t.prototype.submitRequest=function(e,t,n){return e.send(t)},t.prototype._finished=function(e,n,r){var o,i,s +if(o)return}for(d=[],l=0,c=e.length;l=U;p=0<=U?++A:--A)i.append(this._getParamName(p),e[p],this._renameFilename(e[p].name)) +return this.submitRequest(E,i,e)},t.prototype.submitRequest=function(e,t,n){return e.send(t)},t.prototype._finished=function(e,n,r){var o,i,s for(i=0,s=e.length;ip;)t=o[4*(l-1)+3],0===t?i=l:p=l, l=i+p>>1 -return u=l/s,0===u?1:u},a=function(e,t,n,r,o,i,a,l,u,p){var d -return d=s(t),e.drawImage(t,n,r,o,i,a,l,u,p/d)},i=function(e,t){var n,r,o,i,s,a,l,u,p +return u=l/s,0===u?1:u},a=function(e,t,n,r,o,i,a,l,u,p){var c +return c=s(t),e.drawImage(t,n,r,o,i,a,l,u,p/c)},i=function(e,t){var n,r,o,i,s,a,l,u,p if(o=!1,p=!0,r=e.document,u=r.documentElement,n=r.addEventListener?"addEventListener":"attachEvent",l=r.addEventListener?"removeEventListener":"detachEvent",a=r.addEventListener?"":"on",i=function(n){if("readystatechange"!==n.type||"complete"===r.readyState)return("load"===n.type?e:r)[l](a+n.type,i,!1), !o&&(o=!0)?t.call(e,n.type||n):void 0},s=function(){var e -try{u.doScroll("left")}catch(t){return e=t,void setTimeout(s,50)}return i("poll")},"complete"!==r.readyState){if(r.createEventObject&&u.doScroll){try{p=!e.frameElement}catch(d){}p&&s()}return r[n](a+"DOMContentLoaded",i,!1), -r[n](a+"readystatechange",i,!1),e[n](a+"load",i,!1)}},n._autoDiscoverFunction=function(){if(n.autoDiscover)return n.discover()},i(window,n._autoDiscoverFunction)}).call(this)}).call(t,n(18),n(24)(e))},function(e,t){ +try{u.doScroll("left")}catch(t){return e=t,void setTimeout(s,50)}return i("poll")},"complete"!==r.readyState){if(r.createEventObject&&u.doScroll){try{p=!e.frameElement}catch(c){}p&&s()}return r[n](a+"DOMContentLoaded",i,!1), +r[n](a+"readystatechange",i,!1),e[n](a+"load",i,!1)}},n._autoDiscoverFunction=function(){if(n.autoDiscover)return n.discover()},i(window,n._autoDiscoverFunction)}).call(this)}).call(t,n(20),n(26)(e))},function(e,t){ e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},function(e,t){e.exports=DataFormat},function(e,t,n){"use strict" function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called") @@ -570,21 +595,21 @@ return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("funct e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return{gallery:e.assetAdmin.gallery }}Object.defineProperty(t,"__esModule",{value:!0}),t.BulkActions=void 0 var l=function(){function e(e,t){for(var n=0;n0 + +}},{key:"isImageSmallerThanThumbnail",value:function _(){if(!this.isImage()||!this.exists()&&!this.uploading())return!1 +var e=this.props.item.width,t=this.props.item.height +return t&&e&&t=0)return!0}return!1})},filterByColumnFilters:function M(e){var t=Object.keys(e).reduce(function(t,n){return D(t,function(t){ -return y.getAt(t,n||"").toString().toLowerCase().indexOf(e[n].toLowerCase())>=0})},this.props.results),n={columnFilters:e} +},defaultFilter:function L(e,t){var n=this +return k(e,function(e){for(var r=v.keys(e),o=0;o=0)return!0}return!1})},filterByColumnFilters:function M(e){var t=Object.keys(e).reduce(function(t,n){return k(t,function(t){ +return v.getAt(t,n||"").toString().toLowerCase().indexOf(e[n].toLowerCase())>=0})},this.props.results),n={columnFilters:e} e?(n.filteredResults=t,n.maxPage=this.getMaxPage(n.filteredResults)):this.state.filter?n.filteredResults=this.props.useCustomFilterer?this.props.customFilterer(this.props.results,filter):this.defaultFilter(this.props.results,filter):n.filteredResults=null, -this.setState(n)},filterByColumn:function H(e,t){var n=this.state.columnFilters -if(n.hasOwnProperty(t)&&!e)n=I(n,t) +this.setState(n)},filterByColumn:function z(e,t){var n=this.state.columnFilters +if(n.hasOwnProperty(t)&&!e)n=T(n,t) else{var r={} -r[t]=e,n=O({},n,r)}this.filterByColumnFilters(n)},setFilter:function z(e){if(this.props.useExternal)return void this.props.externalSetFilter(e) +r[t]=e,n=A({},n,r)}this.filterByColumnFilters(n)},setFilter:function q(e){if(this.props.useExternal)return void this.props.externalSetFilter(e) var t=this,n={page:0,filter:e} -n.filteredResults=this.props.useCustomFilterer?this.props.customFilterer(this.props.results,e):this.defaultFilter(this.props.results,e),n.maxPage=t.getMaxPage(n.filteredResults),(T(e)||F(e)||x(e))&&(n.filter=e, +n.filteredResults=this.props.useCustomFilterer?this.props.customFilterer(this.props.results,e):this.defaultFilter(this.props.results,e),n.maxPage=t.getMaxPage(n.filteredResults),(I(e)||F(e)||P(e))&&(n.filter=e, n.filteredResults=null),t.setState(n),this._resetSelectedRows()},setPageSize:function B(e){return this.props.useExternal?(this.setState({resultsPerPage:e}),void this.props.externalSetPageSize(e)):(this.state.resultsPerPage=e, -void this.setMaxPage())},toggleColumnChooser:function G(){this.setState({showColumnChooser:!this.state.showColumnChooser})},isNullOrUndefined:function q(e){return void 0===e||null===e},shouldUseCustomRowComponent:function V(){ -return this.isNullOrUndefined(this.state.useCustomRowComponent)?this.props.useCustomRowComponent:this.state.useCustomRowComponent},shouldUseCustomGridComponent:function W(){return this.isNullOrUndefined(this.state.useCustomGridComponent)?this.props.useCustomGridComponent:this.state.useCustomGridComponent +void this.setMaxPage())},toggleColumnChooser:function H(){this.setState({showColumnChooser:!this.state.showColumnChooser})},isNullOrUndefined:function G(e){return void 0===e||null===e},shouldUseCustomRowComponent:function V(){ +return this.isNullOrUndefined(this.state.useCustomRowComponent)?this.props.useCustomRowComponent:this.state.useCustomRowComponent},shouldUseCustomGridComponent:function Q(){return this.isNullOrUndefined(this.state.useCustomGridComponent)?this.props.useCustomGridComponent:this.state.useCustomGridComponent -},toggleCustomComponent:function Q(){"grid"===this.state.customComponentType?this.setState({useCustomGridComponent:!this.shouldUseCustomGridComponent()}):"row"===this.state.customComponentType&&this.setState({ -useCustomRowComponent:!this.shouldUseCustomRowComponent()})},getMaxPage:function K(e,t){if(this.props.useExternal)return this.props.externalMaxPage +},toggleCustomComponent:function W(){"grid"===this.state.customComponentType?this.setState({useCustomGridComponent:!this.shouldUseCustomGridComponent()}):"row"===this.state.customComponentType&&this.setState({ +useCustomRowComponent:!this.shouldUseCustomRowComponent()})},getMaxPage:function $(e,t){if(this.props.useExternal)return this.props.externalMaxPage t||(t=(e||this.getCurrentResults()).length) var n=Math.ceil(t/this.state.resultsPerPage) -return n},setMaxPage:function $(e){var t=this.getMaxPage(e) -this.state.maxPage!==t&&this.setState({page:0,maxPage:t,filteredColumns:this.columnSettings.filteredColumns})},setPage:function Z(e){if(this.props.useExternal)return void this.props.externalSetPage(e) +return n},setMaxPage:function K(e){var t=this.getMaxPage(e) +this.state.maxPage!==t&&this.setState({page:0,maxPage:t,filteredColumns:this.columnSettings.filteredColumns})},setPage:function Y(e){if(this.props.useExternal)return void this.props.externalSetPage(e) if(e*this.state.resultsPerPage<=this.state.resultsPerPage*this.state.maxPage){var t=this,n={page:e} -t.setState(n)}this.props.enableInfiniteScroll&&this.setState({isSelectAllChecked:!1})},setColumns:function Y(e){this.columnSettings.filteredColumns=P(e)?e:[e],this.setState({filteredColumns:this.columnSettings.filteredColumns +t.setState(n)}this.props.enableInfiniteScroll&&this.setState({isSelectAllChecked:!1})},setColumns:function Z(e){this.columnSettings.filteredColumns=x(e)?e:[e],this.setState({filteredColumns:this.columnSettings.filteredColumns })},nextPage:function X(){var e=this.getCurrentPage() e0&&this.setPage(e-1)},changeSort:function ee(e){if(this.props.enableSort!==!1){if(this.props.useExternal){var t=this.props.externalSortColumn!==e||!this.props.externalSortAscending @@ -704,14 +728,14 @@ return this.setState({sortColumn:e,sortDirection:t?"asc":"desc"}),void this.prop i=(i+1)%r.length,o=r[i]?r[i]:null var s={page:0,sortColumn:e,sortDirection:o} this.setState(s)}},componentWillReceiveProps:function te(e){if(this.setMaxPage(e.results),e.resultsPerPage!==this.props.resultsPerPage&&this.setPageSize(e.resultsPerPage),this.columnSettings.columnMetadata=e.columnMetadata, -e.results.length>0){var t=y.keys(e.results[0]),n=this.columnSettings.allColumns.length==t.length&&this.columnSettings.allColumns.every(function(e,n){return e===t[n]}) +e.results.length>0){var t=v.keys(e.results[0]),n=this.columnSettings.allColumns.length==t.length&&this.columnSettings.allColumns.every(function(e,n){return e===t[n]}) n||(this.columnSettings.allColumns=t)}else this.columnSettings.allColumns.length>0&&(this.columnSettings.allColumns=[]) if(e.columns!==this.columnSettings.filteredColumns&&(this.columnSettings.filteredColumns=e.columns),e.selectedRowIds){var r=this.getDataForRender(this.getCurrentResults(e.results),this.columnSettings.getColumns(),!0) -this.setState({isSelectAllChecked:this._getAreAllRowsChecked(e.selectedRowIds,A(r,this.props.uniqueIdentifier)),selectedRowIds:e.selectedRowIds})}},getInitialState:function ne(){var e={maxPage:0,page:0, +this.setState({isSelectAllChecked:this._getAreAllRowsChecked(e.selectedRowIds,O(r,this.props.uniqueIdentifier)),selectedRowIds:e.selectedRowIds})}},getInitialState:function ne(){var e={maxPage:0,page:0, filteredResults:null,filteredColumns:[],filter:"",columnFilters:{},resultsPerPage:this.props.resultsPerPage||5,showColumnChooser:!1,isSelectAllChecked:!1,selectedRowIds:this.props.selectedRowIds} -return e},componentWillMount:function re(){this.verifyExternal(),this.verifyCustom(),this.columnSettings=new m(this.props.results.length>0?y.keys(this.props.results[0]):[],this.props.columns,this.props.childrenColumnName,this.props.columnMetadata,this.props.metadataColumns), +return e},componentWillMount:function re(){this.verifyExternal(),this.verifyCustom(),this.columnSettings=new m(this.props.results.length>0?v.keys(this.props.results[0]):[],this.props.columns,this.props.childrenColumnName,this.props.columnMetadata,this.props.metadataColumns), this.rowSettings=new g(this.props.rowMetadata,this.props.useCustomTableRowComponent&&this.props.customTableRowComponent?this.props.customTableRowComponent:p,this.props.useCustomTableRowComponent),this.props.initialSort&&this.changeSort(this.props.initialSort), this.setMaxPage(),this.shouldUseCustomGridComponent()?this.setState({customComponentType:"grid"}):this.shouldUseCustomRowComponent()?this.setState({customComponentType:"row"}):this.setState({filteredColumns:this.columnSettings.filteredColumns })},componentDidMount:function oe(){if(this.props.componentDidMount&&"function"==typeof this.props.componentDidMount)return this.props.componentDidMount()},verifyExternal:function ie(){this.props.useExternal===!0&&(null===this.props.externalSetPage&&console.error("useExternal is set to true but there is no externalSetPage function specified."), @@ -722,49 +746,49 @@ verifyCustom:function se(){this.props.useCustomGridComponent===!0&&null===this.p this.props.useCustomGridComponent===!0&&this.props.useCustomRowComponent===!0&&console.error("Cannot currently use both customGridComponent and customRowComponent."),this.props.useCustomFilterer===!0&&null===this.props.customFilterer&&console.error("useCustomFilterer is set to true but no custom filter function was specified."), this.props.useCustomFilterComponent===!0&&null===this.props.customFilterComponent&&console.error("useCustomFilterComponent is set to true but no customFilterComponent was specified.")},getDataForRender:function ae(e,t,n){ var r=this,o=this -if(""!==this.state.sortColumn){var i=this.state.sortColumn,s=D(this.props.columnMetadata,{columnName:i}),a,l={columns:[],orders:[]} +if(""!==this.state.sortColumn){var i=this.state.sortColumn,s=k(this.props.columnMetadata,{columnName:i}),a,l={columns:[],orders:[]} if(s.length>0&&(a=s[0].hasOwnProperty("customCompareFn")&&s[0].customCompareFn,s[0].multiSort&&(l=s[0].multiSort)),this.state.sortDirection)if("function"==typeof a)2===a.length?(e=e.sort(function(e,t){ -return a(R(e,i),R(t,i))}),"desc"===this.state.sortDirection&&e.reverse()):1===a.length&&(e=k(e,function(e){return a(R(e,i))},[this.state.sortDirection])) +return a(R(e,i),R(t,i))}),"desc"===this.state.sortDirection&&e.reverse()):1===a.length&&(e=D(e,function(e){return a(R(e,i))},[this.state.sortDirection])) else{var u=[N(i)],p=[this.state.sortDirection] -l.columns.forEach(function(e,t){u.push(N(e)),"asc"===l.orders[t]||"desc"===l.orders[t]?p.push(l.orders[t]):p.push(r.state.sortDirection)}),e=k(e,u,p)}}var d=this.getCurrentPage() -if(!this.props.useExternal&&n&&this.state.resultsPerPage*(d+1)<=this.state.resultsPerPage*this.state.maxPage&&d>=0)if(this.isInfiniteScrollEnabled())e=E(e,(d+1)*this.state.resultsPerPage) -else{var c=v(e,d*this.state.resultsPerPage) -e=(b||S)(c,c.length-this.state.resultsPerPage)}for(var f=this.columnSettings.getMetadataColumns,h=[],m=0;m=0)if(this.isInfiniteScrollEnabled())e=_(e,(c+1)*this.state.resultsPerPage) +else{var d=y(e,c*this.state.resultsPerPage) +e=(b||w)(d,d.length-this.state.resultsPerPage)}for(var f=this.columnSettings.getMetadataColumns,h=[],m=0;m0&&(g.children=o.getDataForRender(g[o.props.childrenColumnName],t,!1),"children"!==o.props.childrenColumnName&&delete g[o.props.childrenColumnName]), h.push(g)}return h},getCurrentResults:function le(e){return this.state.filteredResults||e||this.props.results},getCurrentPage:function ue(){return this.props.externalCurrentPage||this.state.page},getCurrentSort:function pe(){ -return this.props.useExternal?this.props.externalSortColumn:this.state.sortColumn},getCurrentSortAscending:function de(){return this.props.useExternal?this.props.externalSortAscending:"asc"===this.state.sortDirection +return this.props.useExternal?this.props.externalSortColumn:this.state.sortColumn},getCurrentSortAscending:function ce(){return this.props.useExternal?this.props.externalSortAscending:"asc"===this.state.sortDirection -},getCurrentMaxPage:function ce(){return this.props.useExternal?this.props.externalMaxPage:this.state.maxPage},getSortObject:function fe(){return{enableSort:this.props.enableSort,changeSort:this.changeSort, +},getCurrentMaxPage:function de(){return this.props.useExternal?this.props.externalMaxPage:this.state.maxPage},getSortObject:function fe(){return{enableSort:this.props.enableSort,changeSort:this.changeSort, sortColumn:this.getCurrentSort(),sortAscending:this.getCurrentSortAscending(),sortDirection:this.state.sortDirection,sortAscendingClassName:this.props.sortAscendingClassName,sortDescendingClassName:this.props.sortDescendingClassName, sortAscendingComponent:this.props.sortAscendingComponent,sortDescendingComponent:this.props.sortDescendingComponent,sortDefaultComponent:this.props.sortDefaultComponent}},_toggleSelectAll:function he(){ var e=this.getDataForRender(this.getCurrentResults(),this.columnSettings.getColumns(),!0),t=!this.state.isSelectAllChecked,n=JSON.parse(JSON.stringify(this.state.selectedRowIds)),r=this -_(e,function(e){r._updateSelectedRowIds(e[r.props.uniqueIdentifier],n,t)},this),this.setState({isSelectAllChecked:t,selectedRowIds:n}),this.props.onSelectionChange&&this.props.onSelectionChange(n,t)},_toggleSelectRow:function me(e,t){ +E(e,function(e){r._updateSelectedRowIds(e[r.props.uniqueIdentifier],n,t)},this),this.setState({isSelectAllChecked:t,selectedRowIds:n}),this.props.onSelectionChange&&this.props.onSelectionChange(n,t)},_toggleSelectRow:function me(e,t){ var n=this.getDataForRender(this.getCurrentResults(),this.columnSettings.getColumns(),!0),r=JSON.parse(JSON.stringify(this.state.selectedRowIds)) this._updateSelectedRowIds(e[this.props.uniqueIdentifier],r,t) -var o=this._getAreAllRowsChecked(r,A(n,this.props.uniqueIdentifier)) +var o=this._getAreAllRowsChecked(r,O(n,this.props.uniqueIdentifier)) this.setState({isSelectAllChecked:o,selectedRowIds:r}),this.props.onSelectionChange&&this.props.onSelectionChange(r,o)},_updateSelectedRowIds:function ge(e,t,n){var r -n?(r=C(t,function(t){return e===t}),void 0===r&&t.push(e)):t.splice(t.indexOf(e),1)},_getIsSelectAllChecked:function ye(){return this.state.isSelectAllChecked},_getAreAllRowsChecked:function ve(e,t){return t.length===w(t,e).length +n?(r=C(t,function(t){return e===t}),void 0===r&&t.push(e)):t.splice(t.indexOf(e),1)},_getIsSelectAllChecked:function ve(){return this.state.isSelectAllChecked},_getAreAllRowsChecked:function ye(e,t){return t.length===S(t,e).length -},_getIsRowChecked:function be(e){return this.state.selectedRowIds.indexOf(e[this.props.uniqueIdentifier])>-1},getSelectedRowIds:function Ce(){return this.state.selectedRowIds},_resetSelectedRows:function Ee(){ -this.setState({isSelectAllChecked:!1,selectedRowIds:[]})},getMultipleSelectionObject:function _e(){return{isMultipleSelection:!C(this.props.results,function(e){return"children"in e})&&this.props.isMultipleSelection, +},_getIsRowChecked:function be(e){return this.state.selectedRowIds.indexOf(e[this.props.uniqueIdentifier])>-1},getSelectedRowIds:function Ce(){return this.state.selectedRowIds},_resetSelectedRows:function _e(){ +this.setState({isSelectAllChecked:!1,selectedRowIds:[]})},getMultipleSelectionObject:function Ee(){return{isMultipleSelection:!C(this.props.results,function(e){return"children"in e})&&this.props.isMultipleSelection, toggleSelectAll:this._toggleSelectAll,getIsSelectAllChecked:this._getIsSelectAllChecked,toggleSelectRow:this._toggleSelectRow,getSelectedRowIds:this.getSelectedRowIds,getIsRowChecked:this._getIsRowChecked -}},isInfiniteScrollEnabled:function Se(){return!this.props.useCustomPagerComponent&&this.props.enableInfiniteScroll},getClearFixStyles:function we(){return{clear:"both",display:"table",width:"100%"}},getSettingsStyles:function Pe(){ -return{"float":"left",width:"50%",textAlign:"right"}},getFilterStyles:function xe(){return{"float":"left",width:"50%",textAlign:"left",color:"#222",minHeight:"1px"}},getFilter:function Fe(){return this.props.showFilter&&this.shouldUseCustomGridComponent()===!1?this.props.useCustomFilterComponent?o.createElement(h,{ +}},isInfiniteScrollEnabled:function we(){return!this.props.useCustomPagerComponent&&this.props.enableInfiniteScroll},getClearFixStyles:function Se(){return{clear:"both",display:"table",width:"100%"}},getSettingsStyles:function xe(){ +return{"float":"left",width:"50%",textAlign:"right"}},getFilterStyles:function Pe(){return{"float":"left",width:"50%",textAlign:"left",color:"#222",minHeight:"1px"}},getFilter:function Fe(){return this.props.showFilter&&this.shouldUseCustomGridComponent()===!1?this.props.useCustomFilterComponent?o.createElement(h,{ changeFilter:this.setFilter,placeholderText:this.props.filterPlaceholderText,customFilterComponent:this.props.customFilterComponent,results:this.props.results,currentResults:this.getCurrentResults()}):o.createElement(s,{ -changeFilter:this.setFilter,placeholderText:this.props.filterPlaceholderText}):""},getSettings:function Te(){return this.props.showSettings?o.createElement("button",{type:"button",className:this.props.settingsToggleClassName, -onClick:this.toggleColumnChooser,style:this.props.useGriddleStyles?{background:"none",border:"none",padding:0,margin:0,fontSize:14}:null},this.props.settingsText,this.props.settingsIconComponent):""},getTopSection:function Ie(e,t){ +changeFilter:this.setFilter,placeholderText:this.props.filterPlaceholderText}):""},getSettings:function Ie(){return this.props.showSettings?o.createElement("button",{type:"button",className:this.props.settingsToggleClassName, +onClick:this.toggleColumnChooser,style:this.props.useGriddleStyles?{background:"none",border:"none",padding:0,margin:0,fontSize:14}:null},this.props.settingsText,this.props.settingsIconComponent):""},getTopSection:function Te(e,t){ if(this.props.showFilter===!1&&this.props.showSettings===!1)return"" var n=null,r=null,i=null return this.props.useGriddleStyles&&(n=this.getFilterStyles(),r=this.getSettingsStyles(),i=this.getClearFixStyles()),o.createElement("div",{className:"top-section",style:i},o.createElement("div",{className:"griddle-filter", -style:n},e),o.createElement("div",{className:"griddle-settings-toggle",style:r},t))},getPagingSection:function Ae(e,t){if((this.props.showPager&&!this.isInfiniteScrollEnabled()&&!this.shouldUseCustomGridComponent())!==!1)return o.createElement("div",{ +style:n},e),o.createElement("div",{className:"griddle-settings-toggle",style:r},t))},getPagingSection:function Oe(e,t){if((this.props.showPager&&!this.isInfiniteScrollEnabled()&&!this.shouldUseCustomGridComponent())!==!1)return o.createElement("div",{ className:"griddle-footer"},this.props.useCustomPagerComponent?o.createElement(f,{customPagerComponentOptions:this.props.customPagerComponentOptions,next:this.nextPage,previous:this.previousPage,currentPage:e, maxPage:t,setPage:this.setPage,nextText:this.props.nextText,previousText:this.props.previousText,customPagerComponent:this.props.customPagerComponent}):o.createElement(a,{useGriddleStyles:this.props.useGriddleStyles, next:this.nextPage,previous:this.previousPage,nextClassName:this.props.nextClassName,nextIconComponent:this.props.nextIconComponent,previousClassName:this.props.previousClassName,previousIconComponent:this.props.previousIconComponent, -currentPage:e,maxPage:t,setPage:this.setPage,nextText:this.props.nextText,previousText:this.props.previousText}))},getColumnSelectorSection:function Oe(e,t){return this.state.showColumnChooser?o.createElement(l,{ +currentPage:e,maxPage:t,setPage:this.setPage,nextText:this.props.nextText,previousText:this.props.previousText}))},getColumnSelectorSection:function Ae(e,t){return this.state.showColumnChooser?o.createElement(l,{ columns:e,selectedColumns:t,setColumns:this.setColumns,settingsText:this.props.settingsText,settingsIconComponent:this.props.settingsIconComponent,maxRowsText:this.props.maxRowsText,setPageSize:this.setPageSize, showSetPageSize:!this.shouldUseCustomGridComponent(),resultsPerPage:this.state.resultsPerPage,enableToggleCustom:this.props.enableToggleCustom,toggleCustomComponent:this.toggleCustomComponent,useCustomComponent:this.shouldUseCustomRowComponent()||this.shouldUseCustomGridComponent(), -useGriddleStyles:this.props.useGriddleStyles,enableCustomFormatText:this.props.enableCustomFormatText,columnMetadata:this.props.columnMetadata}):""},getCustomGridSection:function De(){return o.createElement(this.props.customGridComponent,r({ -data:this.props.results,className:this.props.customGridComponentClassName},this.props.gridMetadata))},getCustomRowSection:function ke(e,t,n,r,i){return o.createElement("div",null,o.createElement(c,{data:e, +useGriddleStyles:this.props.useGriddleStyles,enableCustomFormatText:this.props.enableCustomFormatText,columnMetadata:this.props.columnMetadata}):""},getCustomGridSection:function ke(){return o.createElement(this.props.customGridComponent,r({ +data:this.props.results,className:this.props.customGridComponentClassName},this.props.gridMetadata))},getCustomRowSection:function De(e,t,n,r,i){return o.createElement("div",null,o.createElement(d,{data:e, columns:t,metadataColumns:n,globalData:i,className:this.props.customRowComponentClassName,customComponent:this.props.customRowComponent,style:this.props.useGriddleStyles?this.getClearFixStyles():null}),this.props.showPager&&r) },getStandardGridSection:function Ne(e,t,n,r,s){var a=this.getSortObject(),l=this.getMultipleSelectionObject(),u=this.shouldShowNoDataSection(e),p=this.getNoDataSection() @@ -775,24 +799,24 @@ parentRowCollapsedClassName:this.props.parentRowCollapsedClassName,parentRowExpa bodyHeight:this.props.bodyHeight,paddingHeight:this.props.paddingHeight,rowHeight:this.props.rowHeight,infiniteScrollLoadTreshold:this.props.infiniteScrollLoadTreshold,externalLoadingComponent:this.props.externalLoadingComponent, externalIsLoading:this.props.externalIsLoading,hasMorePages:s,onRowClick:this.props.onRowClick}))},getContentSection:function Re(e,t,n,r,o,i){return this.shouldUseCustomGridComponent()&&null!==this.props.customGridComponent?this.getCustomGridSection():this.shouldUseCustomRowComponent()?this.getCustomRowSection(e,t,n,r,i):this.getStandardGridSection(e,t,n,r,o) -},getNoDataSection:function Ue(){return null!=this.props.customNoDataComponent?o.createElement("div",{className:this.props.noDataClassName},o.createElement(this.props.customNoDataComponent,this.props.customNoDataComponentProps)):o.createElement(u,{ -noDataMessage:this.props.noDataMessage})},shouldShowNoDataSection:function Le(e){return!this.props.allowEmptyGrid&&(this.props.useExternal===!1&&("undefined"==typeof e||0===e.length)||this.props.useExternal===!0&&this.props.externalIsLoading===!1&&0===e.length) +},getNoDataSection:function je(){return null!=this.props.customNoDataComponent?o.createElement("div",{className:this.props.noDataClassName},o.createElement(this.props.customNoDataComponent,this.props.customNoDataComponentProps)):o.createElement(u,{ +noDataMessage:this.props.noDataMessage})},shouldShowNoDataSection:function Ue(e){return!this.props.allowEmptyGrid&&(this.props.useExternal===!1&&("undefined"==typeof e||0===e.length)||this.props.useExternal===!0&&this.props.externalIsLoading===!1&&0===e.length) -},render:function je(){var e=this,t=this.getCurrentResults(),n=this.props.tableClassName+" table-header",r=this.getFilter(),i=this.getSettings(),s=this.getTopSection(r,i),a=[],l=this.columnSettings.getColumns(),u=this.getDataForRender(t,l,!0),p=this.columnSettings.getMetadataColumns() +},render:function Le(){var e=this,t=this.getCurrentResults(),n=this.props.tableClassName+" table-header",r=this.getFilter(),i=this.getSettings(),s=this.getTopSection(r,i),a=[],l=this.columnSettings.getColumns(),u=this.getDataForRender(t,l,!0),p=this.columnSettings.getMetadataColumns() -a=y.keys(I(t[0],p)),a=this.columnSettings.orderColumns(a) -var d=this.getCurrentPage(),c=this.getCurrentMaxPage(),f=d+10?"griddle "+this.props.gridClassName:"griddle" +a=v.keys(T(t[0],p)),a=this.columnSettings.orderColumns(a) +var c=this.getCurrentPage(),d=this.getCurrentMaxPage(),f=c+10?"griddle "+this.props.gridClassName:"griddle" -return v+=this.shouldUseCustomRowComponent()?" griddle-custom":"",o.createElement("div",{className:v},s,g,o.createElement("div",{className:"griddle-container",style:this.props.useGriddleStyles&&!this.props.isSubGriddle?{ +return y+=this.shouldUseCustomRowComponent()?" griddle-custom":"",o.createElement("div",{className:y},s,g,o.createElement("div",{className:"griddle-container",style:this.props.useGriddleStyles&&!this.props.isSubGriddle?{ border:"1px solid #DDD"}:null},m))}}) -d.Griddle=e.exports=U},function(e,t,n){"use strict" -var r=n(3),o=n(32),i=n(189),s=n(33),a=n(196),l=r.createClass({displayName:"GridTable",getDefaultProps:function u(){return{data:[],columnSettings:null,rowSettings:null,sortSettings:null,multipleSelectionSettings:null, +c.Griddle=e.exports=j},function(e,t,n){"use strict" +var r=n(3),o=n(34),i=n(191),s=n(35),a=n(198),l=r.createClass({displayName:"GridTable",getDefaultProps:function u(){return{data:[],columnSettings:null,rowSettings:null,sortSettings:null,multipleSelectionSettings:null, className:"",enableInfiniteScroll:!1,nextPage:null,hasMorePages:!1,useFixedHeader:!1,useFixedLayout:!0,paddingHeight:null,rowHeight:null,filterByColumn:null,infiniteScrollLoadTreshold:null,bodyHeight:null, useGriddleStyles:!0,useGriddleIcons:!0,isSubGriddle:!1,parentRowCollapsedClassName:"parent-row",parentRowExpandedClassName:"parent-row expanded",parentRowCollapsedComponent:"â–¶",parentRowExpandedComponent:"â–¼", -externalLoadingComponent:null,externalIsLoading:!1,onRowClick:null}},getInitialState:function p(){return{scrollTop:0,scrollHeight:this.props.bodyHeight,clientHeight:this.props.bodyHeight}},componentDidMount:function d(){ -this.gridScroll()},componentDidUpdate:function c(e,t){this.gridScroll()},gridScroll:function f(){if(this.props.enableInfiniteScroll&&!this.props.externalIsLoading){var e=this.refs.scrollable,t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight +externalLoadingComponent:null,externalIsLoading:!1,onRowClick:null}},getInitialState:function p(){return{scrollTop:0,scrollHeight:this.props.bodyHeight,clientHeight:this.props.bodyHeight}},componentDidMount:function c(){ +this.gridScroll()},componentDidUpdate:function d(e,t){this.gridScroll()},gridScroll:function f(){if(this.props.enableInfiniteScroll&&!this.props.externalIsLoading){var e=this.refs.scrollable,t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight if(null!==this.props.rowHeight&&this.state.scrollTop!==t&&Math.abs(this.state.scrollTop-t)>=this.getAdjustedRowHeight()){var o={scrollTop:t,scrollHeight:n,clientHeight:r} @@ -802,28 +826,28 @@ null===this.props.rowSettings&&console.error("gridTable: The rowSettings prop is this.verifyProps() var e=this,t=!1 if(!this.props.externalIsLoading||this.props.enableInfiniteScroll){var n=e.props.data,o=null,s=null,a=!1 -if(this.props.enableInfiniteScroll&&null!==this.props.rowHeight&&void 0!==this.refs.scrollable){var l=e.getAdjustedRowHeight(),u=Math.ceil(e.state.clientHeight/l),p=Math.max(0,Math.floor(e.state.scrollTop/l)-.25*u),d=Math.min(p+1.25*u,this.props.data.length-1) +if(this.props.enableInfiniteScroll&&null!==this.props.rowHeight&&void 0!==this.refs.scrollable){var l=e.getAdjustedRowHeight(),u=Math.ceil(e.state.clientHeight/l),p=Math.max(0,Math.floor(e.state.scrollTop/l)-.25*u),c=Math.min(p+1.25*u,this.props.data.length-1) -n=n.slice(p,d+1) -var c={height:p*l+"px"} -o=r.createElement("tr",{key:"above-"+c.height,style:c}) -var f={height:(this.props.data.length-d)*l+"px"} +n=n.slice(p,c+1) +var d={height:p*l+"px"} +o=r.createElement("tr",{key:"above-"+d.height,style:d}) +var f={height:(this.props.data.length-c)*l+"px"} s=r.createElement("tr",{key:"below-"+f.height,style:f})}var h=n.map(function(n,o){var s="undefined"!=typeof n.children&&n.children.length>0,a=e.props.rowSettings.getRowKey(n,o) return s&&(t=s),r.createElement(i,{useGriddleStyles:e.props.useGriddleStyles,isSubGriddle:e.props.isSubGriddle,parentRowExpandedClassName:e.props.parentRowExpandedClassName,parentRowCollapsedClassName:e.props.parentRowCollapsedClassName, parentRowExpandedComponent:e.props.parentRowExpandedComponent,parentRowCollapsedComponent:e.props.parentRowCollapsedComponent,data:n,key:a+"-container",uniqueId:a,columnSettings:e.props.columnSettings, rowSettings:e.props.rowSettings,paddingHeight:e.props.paddingHeight,multipleSelectionSettings:e.props.multipleSelectionSettings,rowHeight:e.props.rowHeight,hasChildren:s,tableClassName:e.props.className, onRowClick:e.props.onRowClick})}) if(this.props.showNoData){var m=this.props.columnSettings.getVisibleColumnCount() -h.push(r.createElement("tr",{key:"no-data-section"},r.createElement("td",{colSpan:m},this.props.noDataSection)))}return o&&h.unshift(o),s&&h.push(s),{nodes:h,anyHasChildren:t}}return null},render:function y(){ +h.push(r.createElement("tr",{key:"no-data-section"},r.createElement("td",{colSpan:m},this.props.noDataSection)))}return o&&h.unshift(o),s&&h.push(s),{nodes:h,anyHasChildren:t}}return null},render:function v(){ var e=this,t=[],n=!1,i=this.getNodeContent() i&&(t=i.nodes,n=i.anyHasChildren) var s=null,a=null,l={width:"100%"} if(this.props.useFixedLayout&&(l.tableLayout="fixed"),this.props.enableInfiniteScroll&&(s={position:"relative",overflowY:"scroll",height:this.props.bodyHeight+"px",width:"100%"}),this.props.externalIsLoading){ var u=null,p=null this.props.useGriddleStyles&&(u={textAlign:"center",paddingBottom:"40px"}),p=this.props.columnSettings.getVisibleColumnCount() -var d=this.props.externalLoadingComponent?r.createElement(this.props.externalLoadingComponent,null):r.createElement("div",null,"Loading...") -a=r.createElement("tbody",null,r.createElement("tr",null,r.createElement("td",{style:u,colSpan:p},d)))}var c=this.props.showTableHeading?r.createElement(o,{useGriddleStyles:this.props.useGriddleStyles, +var c=this.props.externalLoadingComponent?r.createElement(this.props.externalLoadingComponent,null):r.createElement("div",null,"Loading...") +a=r.createElement("tbody",null,r.createElement("tr",null,r.createElement("td",{style:u,colSpan:p},c)))}var d=this.props.showTableHeading?r.createElement(o,{useGriddleStyles:this.props.useGriddleStyles, useGriddleIcons:this.props.useGriddleIcons,sortSettings:this.props.sortSettings,multipleSelectionSettings:this.props.multipleSelectionSettings,columnSettings:this.props.columnSettings,filterByColumn:this.props.filterByColumn, rowSettings:this.props.rowSettings}):void 0 n||(t=r.createElement("tbody",null,t)) @@ -831,359 +855,359 @@ var f=r.createElement("tbody",null) if(this.props.showPager){var h=this.props.useGriddleStyles?{padding:"0px",backgroundColor:"#EDEDED",border:"0px",color:"#222",height:this.props.showNoData?"20px":null}:null f=r.createElement("tbody",null,r.createElement("tr",null,r.createElement("td",{colSpan:this.props.multipleSelectionSettings.isMultipleSelection?this.props.columnSettings.getVisibleColumnCount()+1:this.props.columnSettings.getVisibleColumnCount(), style:h,className:"footer-container"},this.props.showNoData?null:this.props.pagingContent)))}return this.props.useFixedHeader?(this.props.useGriddleStyles&&(l.tableLayout="fixed"),r.createElement("div",null,r.createElement("table",{ -className:this.props.className,style:this.props.useGriddleStyles&&l||null},c),r.createElement("div",{ref:"scrollable",onScroll:this.gridScroll,style:s},r.createElement("table",{className:this.props.className, +className:this.props.className,style:this.props.useGriddleStyles&&l||null},d),r.createElement("div",{ref:"scrollable",onScroll:this.gridScroll,style:s},r.createElement("table",{className:this.props.className, style:this.props.useGriddleStyles&&l||null},t,a,f)))):r.createElement("div",{ref:"scrollable",onScroll:this.gridScroll,style:s},r.createElement("table",{className:this.props.className,style:this.props.useGriddleStyles&&l||null -},c,t,a,f))}}) +},d,t,a,f))}}) e.exports=l},function(e,t,n){"use strict" var r=Object.assign||function(e){for(var t=1;t0}},{key:"getMetadataColumnProperty", -value:function c(e,t,n){var r=this.getColumnMetadataByName(e) +value:function p(e){return a(this.columnMetadata,{columnName:e})}},{key:"hasColumnMetadata",value:function c(){return null!==this.columnMetadata&&this.columnMetadata.length>0}},{key:"getMetadataColumnProperty", +value:function d(e,t,n){var r=this.getColumnMetadataByName(e) return"undefined"==typeof r||null===r?n:r.hasOwnProperty(t)?r[t]:n}},{key:"orderColumns",value:function f(e){var t=this,n=100,r=l(e,function(e){var r=a(t.columnMetadata,{columnName:e}) return"undefined"==typeof r||null===r||isNaN(r.order)?n:r.order}) return r}},{key:"getColumns",value:function h(){var e=0===this.filteredColumns.length?this.allColumns:this.filteredColumns return e=u(e,this.metadataColumns),e=this.orderColumns(e)}}]),e}() e.exports=p},function(e,t,n){function r(e,t){var n=a(e)?o:s -return n(e,i(t,3))}var o=n(35),i=n(36),s=n(143),a=n(102) +return n(e,i(t,3))}var o=n(37),i=n(38),s=n(145),a=n(104) e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n-1}var o=n(43) +return n<0?void 0:t[n][1]}var o=n(45) +e.exports=r},function(e,t,n){function r(e){return o(this.__data__,e)>-1}var o=n(45) e.exports=r},function(e,t,n){function r(e,t){var n=this.__data__,r=o(n,e) -return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var o=n(43) -e.exports=r},function(e,t,n){function r(){this.__data__=new o,this.size=0}var o=n(40) +return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var o=n(45) +e.exports=r},function(e,t,n){function r(){this.__data__=new o,this.size=0}var o=n(42) e.exports=r},function(e,t){function n(e){var t=this.__data__,n=t["delete"](e) return this.size=t.size,n}e.exports=n},function(e,t){function n(e){return this.__data__.get(e)}e.exports=n},function(e,t){function n(e){return this.__data__.has(e)}e.exports=n},function(e,t,n){function r(e,t){ var n=this.__data__ if(n instanceof o){var r=n.__data__ if(!i||r.lengthc))return!1 +return n.set(e,t),this.size+=n.size==r?0:1,this}var o=n(80) +e.exports=r},function(e,t,n){function r(e,t,n,a,l){return e===t||(null==e||null==t||!i(e)&&!s(t)?e!==e&&t!==t:o(e,t,n,a,r,l))}var o=n(86),i=n(65),s=n(103) +e.exports=r},function(e,t,n){function r(e,t,n,r,g,y){var b=u(e),C=u(t),_=h,E=h +b||(_=l(e),_=_==f?m:_),C||(E=l(t),E=E==f?m:E) +var w=_==m,S=E==m,x=_==E +if(x&&p(e)){if(!p(t))return!1 +b=!0,w=!1}if(x&&!w)return y||(y=new o),b||c(e)?i(e,t,n,r,g,y):s(e,t,_,n,r,g,y) +if(!(n&d)){var P=w&&v.call(e,"__wrapped__"),F=S&&v.call(t,"__wrapped__") +if(P||F){var I=P?e.value():e,T=F?t.value():t +return y||(y=new o),g(I,T,n,r,y)}}return!!x&&(y||(y=new o),a(e,t,n,r,g,y))}var o=n(41),i=n(87),s=n(93),a=n(97),l=n(118),u=n(104),p=n(105),c=n(108),d=1,f="[object Arguments]",h="[object Array]",m="[object Object]",g=Object.prototype,v=g.hasOwnProperty + + +e.exports=r},function(e,t,n){function r(e,t,n,r,u,p){var c=n&a,d=e.length,f=t.length +if(d!=f&&!(c&&f>d))return!1 var h=p.get(e) if(h&&p.get(t))return h==t -var m=-1,g=!0,y=n&l?new o:void 0 -for(p.set(e,t),p.set(t,e);++m-1&&e%1==0&&e-1&&e%1==0&&e-1&&e%1==0&&e<=r +A[E]=A[w]=A[S]=A[x]=A[P]=A[F]=A[I]=A[T]=A[O]=!0,A[a]=A[l]=A[C]=A[u]=A[_]=A[p]=A[c]=A[d]=A[f]=A[h]=A[m]=A[g]=A[v]=A[y]=A[b]=!1,e.exports=r},function(e,t){function n(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r }var r=9007199254740991 -e.exports=n},function(e,t){function n(e){return function(t){return e(t)}}e.exports=n},function(e,t,n){(function(e){var r=n(60),o="object"==typeof t&&t&&!t.nodeType&&t,i=o&&"object"==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s&&r.process,l=function(){ +e.exports=n},function(e,t){function n(e){return function(t){return e(t)}}e.exports=n},function(e,t,n){(function(e){var r=n(62),o="object"==typeof t&&t&&!t.nodeType&&t,i=o&&"object"==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s&&r.process,l=function(){ try{return a&&a.binding&&a.binding("util")}catch(e){}}() -e.exports=l}).call(t,n(24)(e))},function(e,t,n){function r(e){if(!o(e))return i(e) +e.exports=l}).call(t,n(26)(e))},function(e,t,n){function r(e){if(!o(e))return i(e) var t=[] for(var n in Object(e))a.call(e,n)&&"constructor"!=n&&t.push(n) -return t}var o=n(112),i=n(113),s=Object.prototype,a=s.hasOwnProperty +return t}var o=n(114),i=n(115),s=Object.prototype,a=s.hasOwnProperty e.exports=r},function(e,t){function n(e){var t=e&&e.constructor,n="function"==typeof t&&t.prototype||r return e===n}var r=Object.prototype -e.exports=n},function(e,t,n){var r=n(114),o=r(Object.keys,Object) -e.exports=o},function(e,t){function n(e,t){return function(n){return e(t(n))}}e.exports=n},function(e,t,n){function r(e){return null!=e&&i(e.length)&&!o(e)}var o=n(56),i=n(108) -e.exports=r},function(e,t,n){var r=n(117),o=n(53),i=n(118),s=n(119),a=n(120),l=n(57),u=n(66),p="[object Map]",d="[object Object]",c="[object Promise]",f="[object Set]",h="[object WeakMap]",m="[object DataView]",g=u(r),y=u(o),v=u(i),b=u(s),C=u(a),E=l +e.exports=n},function(e,t,n){var r=n(116),o=r(Object.keys,Object) +e.exports=o},function(e,t){function n(e,t){return function(n){return e(t(n))}}e.exports=n},function(e,t,n){function r(e){return null!=e&&i(e.length)&&!o(e)}var o=n(58),i=n(110) +e.exports=r},function(e,t,n){var r=n(119),o=n(55),i=n(120),s=n(121),a=n(122),l=n(59),u=n(68),p="[object Map]",c="[object Object]",d="[object Promise]",f="[object Set]",h="[object WeakMap]",m="[object DataView]",g=u(r),v=u(o),y=u(i),b=u(s),C=u(a),_=l -;(r&&E(new r(new ArrayBuffer(1)))!=m||o&&E(new o)!=p||i&&E(i.resolve())!=c||s&&E(new s)!=f||a&&E(new a)!=h)&&(E=function(e){var t=l(e),n=t==d?e.constructor:void 0,r=n?u(n):"" +;(r&&_(new r(new ArrayBuffer(1)))!=m||o&&_(new o)!=p||i&&_(i.resolve())!=d||s&&_(new s)!=f||a&&_(new a)!=h)&&(_=function(e){var t=l(e),n=t==c?e.constructor:void 0,r=n?u(n):"" if(r)switch(r){case g:return m -case y:return p -case v:return c +case v:return p +case y:return d case b:return f -case C:return h}return t}),e.exports=E},function(e,t,n){var r=n(54),o=n(59),i=r(o,"DataView") -e.exports=i},function(e,t,n){var r=n(54),o=n(59),i=r(o,"Promise") -e.exports=i},function(e,t,n){var r=n(54),o=n(59),i=r(o,"Set") -e.exports=i},function(e,t,n){var r=n(54),o=n(59),i=r(o,"WeakMap") +case C:return h}return t}),e.exports=_},function(e,t,n){var r=n(56),o=n(61),i=r(o,"DataView") +e.exports=i},function(e,t,n){var r=n(56),o=n(61),i=r(o,"Promise") +e.exports=i},function(e,t,n){var r=n(56),o=n(61),i=r(o,"Set") +e.exports=i},function(e,t,n){var r=n(56),o=n(61),i=r(o,"WeakMap") e.exports=i},function(e,t,n){function r(e){for(var t=i(e),n=t.length;n--;){var r=t[n],s=e[r] -t[n]=[r,s,o(s)]}return t}var o=n(122),i=n(96) -e.exports=r},function(e,t,n){function r(e){return e===e&&!o(e)}var o=n(63) +t[n]=[r,s,o(s)]}return t}var o=n(124),i=n(98) +e.exports=r},function(e,t,n){function r(e){return e===e&&!o(e)}var o=n(65) e.exports=r},function(e,t){function n(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}e.exports=n},function(e,t,n){function r(e,t){return a(e)&&l(t)?u(p(e),t):function(n){ var r=i(n,e) -return void 0===r&&r===t?s(n,e):o(t,r,d|c)}}var o=n(83),i=n(125),s=n(136),a=n(128),l=n(122),u=n(123),p=n(135),d=1,c=2 +return void 0===r&&r===t?s(n,e):o(t,r,c|d)}}var o=n(85),i=n(127),s=n(138),a=n(130),l=n(124),u=n(125),p=n(137),c=1,d=2 e.exports=r},function(e,t,n){function r(e,t,n){var r=null==e?void 0:o(e,t) -return void 0===r?n:r}var o=n(126) +return void 0===r?n:r}var o=n(128) e.exports=r},function(e,t,n){function r(e,t){t=o(t,e) for(var n=0,r=t.length;null!=e&&n-1?a[l?t[u]:u]:void 0}}var o=n(36),i=n(115),s=n(96) +return u>-1?a[l?t[u]:u]:void 0}}var o=n(38),i=n(117),s=n(98) e.exports=r},function(e,t,n){function r(e,t,n){var r=null==e?0:e.length if(!r)return-1 var l=null==n?0:s(n) -return l<0&&(l=a(r+l,0)),o(e,i(t,3),l)}var o=n(155),i=n(36),s=n(156),a=Math.max +return l<0&&(l=a(r+l,0)),o(e,i(t,3),l)}var o=n(157),i=n(38),s=n(158),a=Math.max e.exports=r},function(e,t){function n(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i1&&s(e,t[0],t[1])?t=[]:n>2&&s(t[0],t[1],t[2])&&(t=[t[0]]),o(e,r(t,1),[])}) e.exports=a},function(e,t,n){function r(e,t,n,s,a){var l=-1,u=e.length for(n||(n=i),a||(a=[]);++l0&&n(p)?t>1?r(p,t-1,n,s,a):o(a,p):s||(a[a.length]=p)}return a}var o=n(161),i=n(162) +t>0&&n(p)?t>1?r(p,t-1,n,s,a):o(a,p):s||(a[a.length]=p)}return a}var o=n(163),i=n(164) e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=t.length,o=e.length;++n=l)return u var p=n[r] -return u*("desc"==p?-1:1)}}return e.index-t.index}var o=n(166) +return u*("desc"==p?-1:1)}}return e.index-t.index}var o=n(168) e.exports=r},function(e,t,n){function r(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e===e,s=o(e),a=void 0!==t,l=null===t,u=t===t,p=o(t) if(!l&&!p&&!s&&e>t||s&&a&&u&&!l&&!p||r&&a&&u||!n&&u||!i)return 1 -if(!r&&!s&&!p&&e0){if(++t>=r)return arguments[0]}else t=0 return e.apply(void 0,arguments)}}var r=800,o=16,i=Date.now e.exports=n},function(e,t,n){function r(e,t,n){if(!a(n))return!1 var r=typeof t -return!!("number"==r?i(n)&&s(t,n.length):"string"==r&&t in n)&&o(n[t],e)}var o=n(44),i=n(115),s=n(105),a=n(63) -e.exports=r},function(e,t,n){var r=n(177),o=n(160),i=n(167),s=n(183),a=i(function(e,t){return s(e)?r(e,o(t,1,s,!0)):[]}) -e.exports=a},function(e,t,n){function r(e,t,n,r){var d=-1,c=i,f=!0,h=e.length,m=[],g=t.length +return!!("number"==r?i(n)&&s(t,n.length):"string"==r&&t in n)&&o(n[t],e)}var o=n(46),i=n(117),s=n(107),a=n(65) +e.exports=r},function(e,t,n){var r=n(179),o=n(162),i=n(169),s=n(185),a=i(function(e,t){return s(e)?r(e,o(t,1,s,!0)):[]}) +e.exports=a},function(e,t,n){function r(e,t,n,r){var c=-1,d=i,f=!0,h=e.length,m=[],g=t.length if(!h)return m -n&&(t=a(t,l(n))),r?(c=s,f=!1):t.length>=p&&(c=u,f=!1,t=new o(t)) -e:for(;++d=p&&(d=u,f=!1,t=new o(t)) +e:for(;++c-1}var o=n(179) -e.exports=r},function(e,t,n){function r(e,t,n){return t===t?s(e,t,n):o(e,i,n)}var o=n(155),i=n(180),s=n(181) +return!!n&&o(e,t,0)>-1}var o=n(181) +e.exports=r},function(e,t,n){function r(e,t,n){return t===t?s(e,t,n):o(e,i,n)}var o=n(157),i=n(182),s=n(183) e.exports=r},function(e,t){function n(e){return e!==e}e.exports=n},function(e,t){function n(e,t,n){for(var r=n-1,o=e.length;++r1?n[o-1]:void 0,a=o>2?n[2]:void 0 for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,a&&i(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),t=Object(t);++r0&&(e=r.createElement("button",{type:"button",onClick:this.props.previous,style:this.props.useGriddleStyles?{color:"#222",border:"none",background:"none",margin:"0 0 0 10px"}:null },this.props.previousIconComponent,this.props.previousText)),this.props.currentPage!==this.props.maxPage-1&&(t=r.createElement("button",{type:"button",onClick:this.props.next,style:this.props.useGriddleStyles?{ @@ -1284,12 +1308,12 @@ s=o({textAlign:"right",width:"34%"},a),i=o({textAlign:"center",width:"33%"},a),n return r.createElement("div",{style:this.props.useGriddleStyles?{minHeight:"35px"}:null},r.createElement("div",{className:this.props.previousClassName,style:n},e),r.createElement("div",{className:"griddle-page", style:i},r.createElement("select",{value:this.props.currentPage+1,onChange:this.pageChange},l)," / ",this.props.maxPage),r.createElement("div",{className:this.props.nextClassName,style:s},t))}}) e.exports=i},function(e,t,n){"use strict" -var r=n(3),o=n(201),i=n(205),s=n(152),a=r.createClass({displayName:"GridSettings",getDefaultProps:function l(){return{columns:[],columnMetadata:[],selectedColumns:[],settingsText:"",maxRowsText:"",resultsPerPage:0, +var r=n(3),o=n(203),i=n(207),s=n(154),a=r.createClass({displayName:"GridSettings",getDefaultProps:function l(){return{columns:[],columnMetadata:[],selectedColumns:[],settingsText:"",maxRowsText:"",resultsPerPage:0, enableToggleCustom:!1,useCustomComponent:!1,useGriddleStyles:!0,toggleCustomComponent:function e(){}}},setPageSize:function u(e){var t=parseInt(e.target.value,10) this.props.setPageSize(t)},handleChange:function p(e){var t=e.target.dataset?e.target.dataset.name:e.target.getAttribute("data-name") e.target.checked===!0&&o(this.props.selectedColumns,t)===!1?(this.props.selectedColumns.push(t),this.props.setColumns(this.props.selectedColumns)):this.props.setColumns(i(this.props.selectedColumns,t)) -},render:function d(){var e=this,t=[] +},render:function c(){var e=this,t=[] e.props.useCustomComponent===!1&&(t=this.props.columns.map(function(t,n){var i=o(e.props.selectedColumns,t),a=s(e.props.columnMetadata,{columnName:t}),l=t return"undefined"!=typeof a&&"undefined"!=typeof a.displayName&&null!=a.displayName&&(l=a.displayName),"undefined"!=typeof a&&null!=a&&a.locked?r.createElement("div",{className:"column checkbox"},r.createElement("label",null,r.createElement("input",{ type:"checkbox",disabled:!0,name:"check",checked:i,"data-name":t}),l)):"undefined"!=typeof a&&null!=a&&"undefined"!=typeof a.visible&&a.visible===!1?null:r.createElement("div",{className:"griddle-column-selection checkbox", @@ -1303,31 +1327,31 @@ return r.createElement("div",{className:"griddle-settings",style:this.props.useG className:"griddle-columns",style:this.props.useGriddleStyles?{clear:"both",display:"table",width:"100%",borderBottom:"1px solid #EDEDED",marginBottom:"10px"}:null},t),i,n)}}) e.exports=a},function(e,t,n){function r(e,t,n,r){e=i(e)?e:l(e),n=n&&!r?a(n):0 var p=e.length -return n<0&&(n=u(p+n,0)),s(e)?n<=p&&e.indexOf(t,n)>-1:!!p&&o(e,t,n)>-1}var o=n(179),i=n(115),s=n(202),a=n(156),l=n(203),u=Math.max -e.exports=r},function(e,t,n){function r(e){return"string"==typeof e||!i(e)&&s(e)&&o(e)==a}var o=n(57),i=n(102),s=n(101),a="[object String]" -e.exports=r},function(e,t,n){function r(e){return null==e?[]:o(e,i(e))}var o=n(204),i=n(96) -e.exports=r},function(e,t,n){function r(e,t){return o(t,function(t){return e[t]})}var o=n(35) -e.exports=r},function(e,t,n){var r=n(177),o=n(167),i=n(183),s=o(function(e,t){return i(e)?r(e,t):[]}) +return n<0&&(n=u(p+n,0)),s(e)?n<=p&&e.indexOf(t,n)>-1:!!p&&o(e,t,n)>-1}var o=n(181),i=n(117),s=n(204),a=n(158),l=n(205),u=Math.max +e.exports=r},function(e,t,n){function r(e){return"string"==typeof e||!i(e)&&s(e)&&o(e)==a}var o=n(59),i=n(104),s=n(103),a="[object String]" +e.exports=r},function(e,t,n){function r(e){return null==e?[]:o(e,i(e))}var o=n(206),i=n(98) +e.exports=r},function(e,t,n){function r(e,t){return o(t,function(t){return e[t]})}var o=n(37) +e.exports=r},function(e,t,n){var r=n(179),o=n(169),i=n(185),s=o(function(e,t){return i(e)?r(e,t):[]}) e.exports=s},function(e,t,n){"use strict" var r=n(3),o=r.createClass({displayName:"GridNoData",getDefaultProps:function i(){return{noDataMessage:"No Data"}},render:function s(){var e=this return r.createElement("div",null,this.props.noDataMessage)}}) e.exports=o},function(e,t,n){"use strict" -var r=n(3),o=n(33),i=n(208),s=n(56),a=n(212),l=n(184),u=n(214),p=n(220),d=n(205),c=r.createClass({displayName:"GridRow",getDefaultProps:function f(){return{isChildRow:!1,showChildren:!1,data:{},columnSettings:null, +var r=n(3),o=n(35),i=n(210),s=n(58),a=n(214),l=n(186),u=n(216),p=n(222),c=n(207),d=r.createClass({displayName:"GridRow",getDefaultProps:function f(){return{isChildRow:!1,showChildren:!1,data:{},columnSettings:null, rowSettings:null,hasChildren:!1,useGriddleStyles:!0,useGriddleIcons:!0,isSubGriddle:!1,paddingHeight:null,rowHeight:null,parentRowCollapsedClassName:"parent-row",parentRowExpandedClassName:"parent-row expanded", parentRowCollapsedComponent:"â–¶",parentRowExpandedComponent:"â–¼",onRowClick:null,multipleSelectionSettings:null}},handleClick:function h(e){null!==this.props.onRowClick&&s(this.props.onRowClick)?this.props.onRowClick(this,e):this.props.hasChildren&&this.props.toggleChildren() },handleSelectionChange:function m(e){},handleSelectClick:function g(e){this.props.multipleSelectionSettings.isMultipleSelection&&("checkbox"===e.target.type?this.props.multipleSelectionSettings.toggleSelectRow(this.props.data,this.refs.selected.checked):this.props.multipleSelectionSettings.toggleSelectRow(this.props.data,!this.refs.selected.checked)) -},verifyProps:function y(){null===this.props.columnSettings&&console.error("gridRow: The columnSettings prop is null and it shouldn't be")},formatData:function v(e){return"boolean"==typeof e?String(e):e +},verifyProps:function v(){null===this.props.columnSettings&&console.error("gridRow: The columnSettings prop is null and it shouldn't be")},formatData:function y(e){return"boolean"==typeof e?String(e):e },render:function b(){var e=this this.verifyProps() var t=this,n=null this.props.useGriddleStyles&&(n={margin:"0px",padding:t.props.paddingHeight+"px 5px "+t.props.paddingHeight+"px 5px",height:t.props.rowHeight?this.props.rowHeight-2*t.props.paddingHeight+"px":null,backgroundColor:"#FFF", borderTopColor:"#DDD",color:"#222"}) -var o=this.props.columnSettings.getColumns(),c=a(o,[]),f=l({},this.props.data) -u(f,c) -var h=p(i.pick(f,d(o,"children"))),m=h.map(function(t,o){var i=null,s=e.props.columnSettings.getColumnMetadataByName(t[0]),a=0===o&&e.props.hasChildren&&e.props.showChildren===!1&&e.props.useGriddleIcons?r.createElement("span",{ +var o=this.props.columnSettings.getColumns(),d=a(o,[]),f=l({},this.props.data) +u(f,d) +var h=p(i.pick(f,c(o,"children"))),m=h.map(function(t,o){var i=null,s=e.props.columnSettings.getColumnMetadataByName(t[0]),a=0===o&&e.props.hasChildren&&e.props.showChildren===!1&&e.props.useGriddleIcons?r.createElement("span",{ style:e.props.useGriddleStyles?{fontSize:"10px",marginRight:"5px"}:null},e.props.parentRowCollapsedComponent):0===o&&e.props.hasChildren&&e.props.showChildren&&e.props.useGriddleIcons?r.createElement("span",{ style:e.props.useGriddleStyles?{fontSize:"10px"}:null},e.props.parentRowExpandedComponent):"" if(0===o&&e.props.isChildRow&&e.props.useGriddleStyles&&(n=l(n,{paddingLeft:10})),e.props.columnSettings.hasColumnMetadata()&&"undefined"!=typeof s&&null!==s)if("undefined"!=typeof s.customComponent&&null!==s.customComponent){ @@ -1335,14 +1359,14 @@ var u=r.createElement(s.customComponent,{data:t[1],rowData:f,metadata:s}) i=r.createElement("td",{onClick:e.handleClick,className:s.cssClassName,key:o,style:n},u)}else i=r.createElement("td",{onClick:e.handleClick,className:s.cssClassName,key:o,style:n},a,e.formatData(t[1])) -return i||r.createElement("td",{onClick:e.handleClick,key:o,style:n},a,t[1])}),g,y -if(null!==this.props.onRowClick&&s(this.props.onRowClick)?(g=null,y=this.handleSelectClick):this.props.multipleSelectionSettings&&this.props.multipleSelectionSettings.isMultipleSelection?(g=this.handleSelectClick, -y=null):(g=null,y=null),m&&this.props.multipleSelectionSettings&&this.props.multipleSelectionSettings.isMultipleSelection){var v=this.props.multipleSelectionSettings.getSelectedRowIds() -m.unshift(r.createElement("td",{key:"selection",style:n,className:"griddle-select griddle-select-cell",onClick:y},r.createElement("input",{type:"checkbox",checked:this.props.multipleSelectionSettings.getIsRowChecked(f), +return i||r.createElement("td",{onClick:e.handleClick,key:o,style:n},a,t[1])}),g,v +if(null!==this.props.onRowClick&&s(this.props.onRowClick)?(g=null,v=this.handleSelectClick):this.props.multipleSelectionSettings&&this.props.multipleSelectionSettings.isMultipleSelection?(g=this.handleSelectClick, +v=null):(g=null,v=null),m&&this.props.multipleSelectionSettings&&this.props.multipleSelectionSettings.isMultipleSelection){var y=this.props.multipleSelectionSettings.getSelectedRowIds() +m.unshift(r.createElement("td",{key:"selection",style:n,className:"griddle-select griddle-select-cell",onClick:v},r.createElement("input",{type:"checkbox",checked:this.props.multipleSelectionSettings.getIsRowChecked(f), onChange:this.handleSelectionChange,ref:"selected"})))}var b=t.props.rowSettings&&t.props.rowSettings.getBodyRowMetadataClass(t.props.data)||"standard-row" return t.props.isChildRow?b="child-row":t.props.hasChildren&&(b=t.props.showChildren?this.props.parentRowExpandedClassName:this.props.parentRowCollapsedClassName),r.createElement("tr",{onClick:g,className:b },m)}}) -e.exports=c},function(e,t,n){"use strict" +e.exports=d},function(e,t,n){"use strict" function r(e){for(var t=/\[("|')(.+)\1\]|([^.\[\]]+)/g,n=[],r;null!==(r=t.exec(e));)n.push(r[2]||r[3]) return n}function o(e,t){if("string"==typeof t){if(void 0!==e[t])return e[t] t=r(t)}for(var n=-1,o=t.length;++no?0:o+t),n=n>o?o:n,n<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0 for(var i=Array(o);++r=120&&y.length>=120)?new o(f&&y):void 0}y=e[0] -var v=-1,b=h[0] -e:for(;++v=120&&v.length>=120)?new o(f&&v):void 0}v=e[0] +var y=-1,b=h[0] +e:for(;++y1),t}),a(e,u(e),n),l&&(n=o(n,p|d|c)) +t=r(t,function(t){return t=s(t,e),l||(l=t.length>1),t}),a(e,u(e),n),l&&(n=o(n,p|c|d)) for(var f=t.length;f--;)i(n,t[f]) return n}) -e.exports=f},function(e,t,n){function r(e,t,n,F,T,I){var A,k=t&S,N=t&w,U=t&P -if(n&&(A=T?n(e,F,T,I):n(e)),void 0!==A)return A -if(!E(e))return e -var L=b(e) -if(L){if(A=g(e),!k)return p(e,A)}else{var j=m(e),M=j==O||j==D -if(C(e))return u(e,k) -if(j==R||j==x||M&&!T){if(A=N||M?{}:v(e),!k)return N?c(e,l(A,e)):d(e,a(A,e))}else{if(!X[j])return T?e:{} -A=y(e,j,r,k)}}I||(I=new o) -var H=I.get(e) -if(H)return H -I.set(e,A) -var z=U?N?h:f:N?keysIn:_,B=L?void 0:z(e) -return i(B||e,function(o,i){B&&(i=o,o=e[i]),s(A,i,r(o,t,n,i,e,I))}),A}var o=n(39),i=n(210),s=n(185),a=n(240),l=n(241),u=n(242),p=n(243),d=n(244),c=n(247),f=n(250),h=n(252),m=n(116),g=n(253),y=n(254),v=n(265),b=n(102),C=n(103),E=n(63),_=n(96),S=1,w=2,P=4,x="[object Arguments]",F="[object Array]",T="[object Boolean]",I="[object Date]",A="[object Error]",O="[object Function]",D="[object GeneratorFunction]",k="[object Map]",N="[object Number]",R="[object Object]",U="[object RegExp]",L="[object Set]",j="[object String]",M="[object Symbol]",H="[object WeakMap]",z="[object ArrayBuffer]",B="[object DataView]",G="[object Float32Array]",q="[object Float64Array]",V="[object Int8Array]",W="[object Int16Array]",Q="[object Int32Array]",K="[object Uint8Array]",$="[object Uint8ClampedArray]",Z="[object Uint16Array]",Y="[object Uint32Array]",X={} +e.exports=f},function(e,t,n){function r(e,t,n,F,I,T){var O,D=t&w,N=t&S,j=t&x +if(n&&(O=I?n(e,F,I,T):n(e)),void 0!==O)return O +if(!_(e))return e +var U=b(e) +if(U){if(O=g(e),!D)return p(e,O)}else{var L=m(e),M=L==A||L==k +if(C(e))return u(e,D) +if(L==R||L==P||M&&!I){if(O=N||M?{}:y(e),!D)return N?d(e,l(O,e)):c(e,a(O,e))}else{if(!X[L])return I?e:{} +O=v(e,L,r,D)}}T||(T=new o) +var z=T.get(e) +if(z)return z +T.set(e,O) +var q=j?N?h:f:N?keysIn:E,B=U?void 0:q(e) +return i(B||e,function(o,i){B&&(i=o,o=e[i]),s(O,i,r(o,t,n,i,e,T))}),O}var o=n(41),i=n(212),s=n(187),a=n(242),l=n(243),u=n(244),p=n(245),c=n(246),d=n(249),f=n(252),h=n(254),m=n(118),g=n(255),v=n(256),y=n(267),b=n(104),C=n(105),_=n(65),E=n(98),w=1,S=2,x=4,P="[object Arguments]",F="[object Array]",I="[object Boolean]",T="[object Date]",O="[object Error]",A="[object Function]",k="[object GeneratorFunction]",D="[object Map]",N="[object Number]",R="[object Object]",j="[object RegExp]",U="[object Set]",L="[object String]",M="[object Symbol]",z="[object WeakMap]",q="[object ArrayBuffer]",B="[object DataView]",H="[object Float32Array]",G="[object Float64Array]",V="[object Int8Array]",Q="[object Int16Array]",W="[object Int32Array]",$="[object Uint8Array]",K="[object Uint8ClampedArray]",Y="[object Uint16Array]",Z="[object Uint32Array]",X={} -X[x]=X[F]=X[z]=X[B]=X[T]=X[I]=X[G]=X[q]=X[V]=X[W]=X[Q]=X[k]=X[N]=X[R]=X[U]=X[L]=X[j]=X[M]=X[K]=X[$]=X[Z]=X[Y]=!0,X[A]=X[O]=X[H]=!1,e.exports=r},function(e,t,n){function r(e,t){return e&&o(t,i(t),e)}var o=n(187),i=n(96) +X[P]=X[F]=X[q]=X[B]=X[I]=X[T]=X[H]=X[G]=X[V]=X[Q]=X[W]=X[D]=X[N]=X[R]=X[j]=X[U]=X[L]=X[M]=X[$]=X[K]=X[Y]=X[Z]=!0,X[O]=X[A]=X[z]=!1,e.exports=r},function(e,t,n){function r(e,t){return e&&o(t,i(t),e)}var o=n(189),i=n(98) -e.exports=r},function(e,t,n){function r(e,t){return e&&o(t,i(t),e)}var o=n(187),i=n(217) +e.exports=r},function(e,t,n){function r(e,t){return e&&o(t,i(t),e)}var o=n(189),i=n(219) e.exports=r},function(e,t,n){(function(e){function r(e,t){if(t)return e.slice() var n=e.length,r=u?u(n):new e.constructor(n) -return e.copy(r),r}var o=n(59),i="object"==typeof t&&t&&!t.nodeType&&t,s=i&&"object"==typeof e&&e&&!e.nodeType&&e,a=s&&s.exports===i,l=a?o.Buffer:void 0,u=l?l.allocUnsafe:void 0 -e.exports=r}).call(t,n(24)(e))},function(e,t){function n(e,t){var n=-1,r=e.length +return e.copy(r),r}var o=n(61),i="object"==typeof t&&t&&!t.nodeType&&t,s=i&&"object"==typeof e&&e&&!e.nodeType&&e,a=s&&s.exports===i,l=a?o.Buffer:void 0,u=l?l.allocUnsafe:void 0 +e.exports=r}).call(t,n(26)(e))},function(e,t){function n(e,t){var n=-1,r=e.length for(t||(t=Array(r));++n0)return p["default"].createElement("div",{className:"gallery__progress-bar--complete"}) var t={className:"gallery__progress-bar-progress",style:{width:e.progress+"%"}} return p["default"].createElement("div",{className:"gallery__progress-bar"},p["default"].createElement("div",t))}},{key:"renderTitle",value:function S(e){var t=this.renderProgressBar(e.rowData) -return p["default"].createElement("div",{className:"fill-width"},p["default"].createElement("div",{className:"flexbox-area-grow"},e.data),t)}},{key:"renderSelect",value:function w(e){return p["default"].createElement("input",{ +return p["default"].createElement("div",{className:"fill-width"},p["default"].createElement("div",{className:"flexbox-area-grow"},e.data),t)}},{key:"renderSelect",value:function x(e){return p["default"].createElement("input",{ type:"checkbox",title:h["default"]._t("AssetAdmin.SELECT"),checked:e.data,tabIndex:"-1",onMouseDown:this.preventFocus})}},{key:"renderDate",value:function P(e){return"folder"===e.rowData.type?null:p["default"].createElement("span",null,e.data) -}},{key:"renderThumbnail",value:function x(e){var t=e.data||e.rowData.url -return t?p["default"].createElement("img",{src:t,alt:e.rowData.title,className:"gallery__table-image"}):p["default"].createElement("div",{className:"gallery__table-image--error"})}},{key:"render",value:function F(){ -return p["default"].createElement(c["default"],this.getTableProps())}}]),t}(u.Component) -y.defaultProps=m.galleryViewDefaultProps,y.propTypes=m.galleryViewPropTypes,t["default"]=y},function(e,t,n){"use strict" -function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return function(t){return t({type:d["default"].ADD_QUEUED_FILE,payload:{file:e}})}}function i(e,t){return function(n){var r=t.message -return"string"==typeof t&&(r={value:t,type:"error"}),n({type:d["default"].FAIL_UPLOAD,payload:{queuedId:e,message:r}})}}function s(){return function(e){return e({type:d["default"].PURGE_UPLOAD_QUEUE,payload:null -})}}function a(e){return function(t){return t({type:d["default"].REMOVE_QUEUED_FILE,payload:{queuedId:e}})}}function l(e){return function(t){return t({type:d["default"].SUCCEED_UPLOAD,payload:{queuedId:e -}})}}function u(e,t){return function(n){return n({type:d["default"].UPDATE_QUEUED_FILE,payload:{queuedId:e,updates:t}})}}Object.defineProperty(t,"__esModule",{value:!0}),t.addQueuedFile=o,t.failUpload=i, -t.purgeUploadQueue=s,t.removeQueuedFile=a,t.succeedUpload=l,t.updateQueuedFile=u -var p=n(273),d=r(p)},function(e,t){"use strict" -Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={ADD_QUEUED_FILE:"ADD_QUEUED_FILE",FAIL_UPLOAD:"FAIL_UPLOAD",PURGE_UPLOAD_QUEUE:"PURGE_UPLOAD_QUEUE",REMOVE_QUEUED_FILE:"REMOVE_QUEUED_FILE", -SUCCEED_UPLOAD:"SUCCEED_UPLOAD",UPDATE_QUEUED_FILE:"UPDATE_QUEUED_FILE"}},function(e,t){e.exports=Breadcrumb},function(e,t){e.exports=Toolbar},function(e,t){e.exports=SchemaActions},function(e,t,n){"use strict" +}},{key:"renderThumbnail",value:function F(e){var t=e.data||e.rowData.url +return"folder"===e.rowData.type?p["default"].createElement("div",{className:"gallery__table-image--folder"}):t?p["default"].createElement("img",{src:t,alt:e.rowData.title,className:"gallery__table-image" +}):p["default"].createElement("div",{className:"gallery__table-image--error"})}},{key:"render",value:function I(){return p["default"].createElement(d["default"],this.getTableProps())}}]),t}(u.Component) + + +v.defaultProps=m.galleryViewDefaultProps,v.propTypes=m.galleryViewPropTypes,t["default"]=v},function(e,t){e.exports=ReactApollo},function(e,t){e.exports=GraphQLTag},function(e,t){e.exports=Breadcrumb},function(e,t){ +e.exports=Toolbar},function(e,t,n){"use strict" +function r(e,t){if(void 0===e&&(e={}),i.isQueryInitAction(t)){var n=a({},e),r=e[t.queryId] +if(r&&r.queryString!==t.queryString)throw new Error("Internal Error: may not update existing query string in store") +var p=!1,c=void 0 +t.storePreviousVariables&&r&&r.networkStatus!==u.loading&&(l(r.variables,t.variables)||(p=!0,c=r.variables)) +var d=u.loading +return p?d=u.setVariables:t.isPoll?d=u.poll:t.isRefetch?d=u.refetch:t.isPoll&&(d=u.poll),n[t.queryId]={queryString:t.queryString,variables:t.variables,previousVariables:c,loading:!0,networkError:null,graphQLErrors:null, +networkStatus:d,forceFetch:t.forceFetch,returnPartialData:t.returnPartialData,lastRequestId:t.requestId,metadata:t.metadata},n}if(i.isQueryResultAction(t)){if(!e[t.queryId])return e +if(t.requestId-1}).reduce(function(t,n){return t[n]=a({},e[n],{ +loading:!0,networkStatus:u.loading}),t},{}) +return r}var i=n(279),s=n(280),a=n(282),l=n(331),u +!function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(u=t.NetworkStatus||(t.NetworkStatus={})), +t.queries=r},function(e,t){"use strict" +function n(e){return"APOLLO_QUERY_RESULT"===e.type}function r(e){return"APOLLO_QUERY_ERROR"===e.type}function o(e){return"APOLLO_QUERY_INIT"===e.type}function i(e){return"APOLLO_QUERY_RESULT_CLIENT"===e.type + +}function s(e){return"APOLLO_QUERY_STOP"===e.type}function a(e){return"APOLLO_MUTATION_INIT"===e.type}function l(e){return"APOLLO_MUTATION_RESULT"===e.type}function u(e){return"APOLLO_MUTATION_ERROR"===e.type + +}function p(e){return"APOLLO_UPDATE_QUERY_RESULT"===e.type}function c(e){return"APOLLO_STORE_RESET"===e.type}function d(e){return"APOLLO_SUBSCRIPTION_RESULT"===e.type}t.isQueryResultAction=n,t.isQueryErrorAction=r, +t.isQueryInitAction=o,t.isQueryResultClientAction=i,t.isQueryStopAction=s,t.isMutationInitAction=a,t.isMutationResultAction=l,t.isMutationErrorAction=u,t.isUpdateQueryResultAction=p,t.isStoreResetAction=c, +t.isSubscriptionResultAction=d},function(e,t,n){"use strict" +function r(e){return"StringValue"===e.kind}function o(e){return"BooleanValue"===e.kind}function i(e){return"IntValue"===e.kind}function s(e){return"FloatValue"===e.kind}function a(e){return"Variable"===e.kind + +}function l(e){return"ObjectValue"===e.kind}function u(e){return"ListValue"===e.kind}function p(e){return"EnumValue"===e.kind}function c(e,t,n,d){if(i(n)||s(n))e[t.value]=Number(n.value) +else if(o(n)||r(n))e[t.value]=n.value +else if(l(n)){var f={} +n.fields.map(function(e){return c(f,e.name,e.value,d)}),e[t.value]=f}else if(a(n)){if(!(d&&n.name.value in d))throw new Error('The inline argument "'+n.name.value+'" is expected as a variable but was not provided.') + + +var h=d[n.name.value] +e[t.value]=h}else if(u(n))e[t.value]=n.values.map(function(e){var n={} +return c(n,t,e,d),n[t.value]}) +else{if(!p(n))throw new Error('The inline argument "'+t.value+'" of kind "'+n.kind+'" is not supported.\n Use variables instead of inline arguments to overcome this limitation.') +e[t.value]=n.value}}function d(e,t){if(e.arguments&&e.arguments.length){var n={} +return e.arguments.forEach(function(e){var r=e.name,o=e.value +return c(n,r,o,t)}),f(e.name.value,n)}return e.name.value}function f(e,t){if(t){var n=JSON.stringify(t) +return e+"("+n+")"}return e}function h(e){return e.alias?e.alias.value:e.name.value}function m(e){return"Field"===e.kind}function g(e){return"InlineFragment"===e.kind}function v(e){return e.errors&&e.errors.length + +}function y(e){return _(e)&&"id"===e.type}function b(e,t){return void 0===t&&(t=!1),{type:"id",id:e,generated:t}}function C(e){return _(e)&&"json"===e.type}var _=n(281) +t.storeKeyNameFromField=d,t.storeKeyNameFromFieldNameAndArgs=f,t.resultKeyNameFromField=h,t.isField=m,t.isInlineFragment=g,t.graphQLResultHasError=v,t.isIdValue=y,t.toIdValue=b,t.isJsonValue=C},function(e,t){ +function n(e){var t=typeof e +return null!=e&&("object"==t||"function"==t)}e.exports=n},function(e,t,n){var r=n(283),o=n(300),i=n(301),s=n(311),a=n(314),l=n(315),u=Object.prototype,p=u.hasOwnProperty,c=i(function(e,t){if(a(t)||s(t))return void o(t,l(t),e) + + +for(var n in t)p.call(t,n)&&r(e,n,t[n])}) +e.exports=c},function(e,t,n){function r(e,t,n){var r=e[t] +a.call(e,t)&&i(r,n)&&(void 0!==n||t in e)||o(e,t,n)}var o=n(284),i=n(299),s=Object.prototype,a=s.hasOwnProperty +e.exports=r},function(e,t,n){function r(e,t,n){"__proto__"==t&&o?o(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var o=n(285) +e.exports=r},function(e,t,n){var r=n(286),o=function(){try{var e=r(Object,"defineProperty") +return e({},"",{}),e}catch(t){}}() +e.exports=o},function(e,t,n){function r(e,t){var n=i(e,t) +return o(n)?n:void 0}var o=n(287),i=n(298) +e.exports=r},function(e,t,n){function r(e){if(!s(e)||i(e))return!1 +var t=o(e)?h:u +return t.test(a(e))}var o=n(288),i=n(295),s=n(281),a=n(297),l=/[\\^$.*+?()[\]{}|]/g,u=/^\[object .+?Constructor\]$/,p=Function.prototype,c=Object.prototype,d=p.toString,f=c.hasOwnProperty,h=RegExp("^"+d.call(f).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$") + + +e.exports=r},function(e,t,n){function r(e){if(!i(e))return!1 +var t=o(e) +return t==a||t==l||t==s||t==u}var o=n(289),i=n(281),s="[object AsyncFunction]",a="[object Function]",l="[object GeneratorFunction]",u="[object Proxy]" +e.exports=r},function(e,t,n){function r(e){return null==e?void 0===e?l:a:(e=Object(e),u&&u in e?i(e):s(e))}var o=n(290),i=n(293),s=n(294),a="[object Null]",l="[object Undefined]",u=o?o.toStringTag:void 0 + + +e.exports=r},function(e,t,n){var r=n(291),o=r.Symbol +e.exports=o},function(e,t,n){var r=n(292),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")() +e.exports=i},function(e,t){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t +e.exports=n}).call(t,function(){return this}())},function(e,t,n){function r(e){var t=s.call(e,l),n=e[l] +try{e[l]=void 0 +var r=!0}catch(o){}var i=a.call(e) +return r&&(t?e[l]=n:delete e[l]),i}var o=n(290),i=Object.prototype,s=i.hasOwnProperty,a=i.toString,l=o?o.toStringTag:void 0 +e.exports=r},function(e,t){function n(e){return o.call(e)}var r=Object.prototype,o=r.toString +e.exports=n},function(e,t,n){function r(e){return!!i&&i in e}var o=n(296),i=function(){var e=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||"") +return e?"Symbol(src)_1."+e:""}() +e.exports=r},function(e,t,n){var r=n(291),o=r["__core-js_shared__"] +e.exports=o},function(e,t){function n(e){if(null!=e){try{return o.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var r=Function.prototype,o=r.toString +e.exports=n},function(e,t){function n(e,t){return null==e?void 0:e[t]}e.exports=n},function(e,t){function n(e,t){return e===t||e!==e&&t!==t}e.exports=n},function(e,t,n){function r(e,t,n,r){var s=!n +n||(n={}) +for(var a=-1,l=t.length;++a1?n[o-1]:void 0,a=o>2?n[2]:void 0 +for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,a&&i(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),t=Object(t);++r0){if(++t>=r)return arguments[0]}else t=0 +return e.apply(void 0,arguments)}}var r=800,o=16,i=Date.now +e.exports=n},function(e,t,n){function r(e,t,n){if(!a(n))return!1 +var r=typeof t +return!!("number"==r?i(n)&&s(t,n.length):"string"==r&&t in n)&&o(n[t],e)}var o=n(299),i=n(311),s=n(313),a=n(281) +e.exports=r},function(e,t,n){function r(e){return null!=e&&i(e.length)&&!o(e)}var o=n(288),i=n(312) +e.exports=r},function(e,t){function n(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}var r=9007199254740991 +e.exports=n},function(e,t){function n(e,t){return t=null==t?r:t,!!t&&("number"==typeof e||o.test(e))&&e>-1&&e%1==0&&e-1}var o=n(338) +e.exports=r},function(e,t,n){function r(e,t){var n=this.__data__,r=o(n,e) +return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var o=n(338) +e.exports=r},function(e,t,n){function r(){this.__data__=new o,this.size=0}var o=n(335) +e.exports=r},function(e,t){function n(e){var t=this.__data__,n=t["delete"](e) +return this.size=t.size,n}e.exports=n},function(e,t){function n(e){return this.__data__.get(e)}e.exports=n},function(e,t){function n(e){return this.__data__.has(e)}e.exports=n},function(e,t,n){function r(e,t){ +var n=this.__data__ +if(n instanceof o){var r=n.__data__ +if(!i||r.lengthd))return!1 +var h=p.get(e) +if(h&&p.get(t))return h==t +var m=-1,g=!0,v=n&l?new o:void 0 +for(p.set(e,t),p.set(t,e);++m0 +}},{key:"exists",value:function h(){return this.props.item.exists}},{key:"uploading",value:function g(){return!!this.props.item.uploaded}},{key:"complete",value:function v(){return this.uploading()&&this.props.item.id>0 }},{key:"isImageSmallerThanThumbnail",value:function b(){if(!this.isImage()||!this.exists()&&!this.uploading())return!1 -var e=this.props.item.dimensions -return e&&e.height0&&o<100?h["default"].createElement("div",{className:"preview__progress" },h["default"].createElement("div",{className:"preview__progress-bar",style:{width:o+"%"}})):null,a=this.props.upload.message,l=null return a?l=h["default"].createElement("div",{className:"preview__message preview__message--"+a.type},a.value):100===o&&(l=h["default"].createElement("div",{className:"preview__message preview__message--success" -},c["default"]._t("AssetAdmin.REPlACE_FILE_SUCCESS","Upload successful, the file will be replaced when you Save."))),h["default"].createElement("div",{className:"editor__thumbnail-container"},i||r,s,l) +},d["default"]._t("AssetAdmin.REPlACE_FILE_SUCCESS","Upload successful, the file will be replaced when you Save."))),h["default"].createElement("div",{className:"editor__thumbnail-container"},i||r,s,l) -}},{key:"renderToolbar",value:function P(){var e=this.canEdit() +}},{key:"renderToolbar",value:function x(){var e=this.canEdit() return this.props.data.url||e?h["default"].createElement("div",{className:"preview__toolbar fill-height"},this.props.data.url?h["default"].createElement("a",{href:this.props.data.url,target:"_blank",className:"preview__toolbar-button--link preview__toolbar-button" },"Open"):null,e?h["default"].createElement("button",{id:"preview-replace-button",onClick:this.preventDefault,className:"preview__toolbar-button--replace preview__toolbar-button"},"Replace"):null,this.props.upload.progress||this.props.upload.message?h["default"].createElement("button",{ -onClick:this.handleCancelUpload,className:"preview__toolbar-button--remove preview__toolbar-button"},"Remove"):null):null}},{key:"render",value:function x(){var e=this.getDropzoneProps() +onClick:this.handleCancelUpload,className:"preview__toolbar-button--remove preview__toolbar-button"},"Remove"):null):null}},{key:"render",value:function P(){var e=this.getDropzoneProps() if(this.canEdit())return h["default"].createElement(g["default"],e,this.renderImage(),this.renderToolbar()) var t=["preview__container",this.props.className,this.props.extraClass] return h["default"].createElement("div",{className:t.join(" ")},this.renderImage(),this.renderToolbar())}}]),t}(f.Component) -w.propTypes={id:f.PropTypes.string.isRequired,name:f.PropTypes.string,className:f.PropTypes.string,extraClass:f.PropTypes.string,readOnly:f.PropTypes.bool,disabled:f.PropTypes.bool,onAutofill:f.PropTypes.func, -data:f.PropTypes.shape({parentid:f.PropTypes.number,url:f.PropTypes.string,exists:f.PropTypes.bool,preview:f.PropTypes.string,category:f.PropTypes.string,nameField:f.PropTypes.string,uploadFileEndpoint:f.PropTypes.shape({ -url:f.PropTypes.string.isRequired,method:f.PropTypes.string.isRequired,payloadFormat:f.PropTypes.string}),initialValues:f.PropTypes.object}).isRequired,upload:f.PropTypes.shape({url:f.PropTypes.string, -progress:f.PropTypes.number,xhr:f.PropTypes.object,category:f.PropTypes.string,message:f.PropTypes.shape({type:f.PropTypes.string.isRequired,value:f.PropTypes.string.isRequired})}),actions:f.PropTypes.object, -securityID:f.PropTypes.string,confirm:f.PropTypes.func},w.defaultProps={extraClass:"",className:"",data:{},upload:{},confirm:function P(e){return window.confirm(e)}},t["default"]=(0,b.connect)(l,u)(w)},function(e,t,n){ -"use strict" +S.propTypes={id:f.PropTypes.string.isRequired,name:f.PropTypes.string,className:f.PropTypes.string,extraClass:f.PropTypes.string,readOnly:f.PropTypes.bool,disabled:f.PropTypes.bool,onAutofill:f.PropTypes.func, +data:f.PropTypes.shape({parentid:f.PropTypes.number,version:f.PropTypes.number,url:f.PropTypes.string,exists:f.PropTypes.bool,preview:f.PropTypes.string,category:f.PropTypes.string,nameField:f.PropTypes.string, +uploadFileEndpoint:f.PropTypes.shape({url:f.PropTypes.string.isRequired,method:f.PropTypes.string.isRequired,payloadFormat:f.PropTypes.string}),initialValues:f.PropTypes.object}).isRequired,upload:f.PropTypes.shape({ +url:f.PropTypes.string,progress:f.PropTypes.number,xhr:f.PropTypes.object,category:f.PropTypes.string,message:f.PropTypes.shape({type:f.PropTypes.string.isRequired,value:f.PropTypes.string.isRequired}) +}),actions:f.PropTypes.object,securityID:f.PropTypes.string,confirm:f.PropTypes.func},S.defaultProps={extraClass:"",className:"",data:{},upload:{},confirm:function x(e){return window.confirm(e)}},t["default"]=(0, +b.connect)(l,u)(S)},function(e,t,n){"use strict" function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return{type:u["default"].PREVIEWFIELD_REMOVE_FILE,payload:{id:e}}}function i(e,t){return{type:u["default"].PREVIEWFIELD_ADD_FILE,payload:{ id:e,file:t}}}function s(e,t){return{type:u["default"].PREVIEWFIELD_FAIL_UPLOAD,payload:{id:e,message:t}}}function a(e,t){return{type:u["default"].PREVIEWFIELD_UPDATE_FILE,payload:{id:e,data:t}}}Object.defineProperty(t,"__esModule",{ value:!0}),t.removeFile=o,t.addFile=i,t.failUpload=s,t.updateFile=a -var l=n(290),u=r(l)},function(e,t,n){"use strict" +var l=n(393),u=r(l)},function(e,t,n){"use strict" function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called") @@ -1846,7 +2122,7 @@ e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,wri return{sectionConfig:t,historySchemaUrl:t.form.fileHistoryForm.schemaUrl}}Object.defineProperty(t,"__esModule",{value:!0}),t.HistoryList=void 0 var l=Object.assign||function(e){for(var t=1;t { const details = { - dimensions: { - height: preview.height, - width: preview.width, - }, + height: preview.height, + width: preview.width, category: this.getFileCategory(file.type), filename: file.name, queuedId: file._queuedId, @@ -360,6 +358,8 @@ class AssetDropzone extends SilverStripeComponent { extension: getFileExtension(file.name), type: file.type, url: preview.thumbnailURL, + thumbnail: preview.thumbnailURL, + smallThumbail: preview.thumbnailURL, }; this.props.handleAddedFile(details); diff --git a/client/src/components/GalleryItem/GalleryItem.js b/client/src/components/GalleryItem/GalleryItem.js index 6180e366d..091fef15d 100644 --- a/client/src/components/GalleryItem/GalleryItem.js +++ b/client/src/components/GalleryItem/GalleryItem.js @@ -195,6 +195,17 @@ class GalleryItem extends SilverStripeComponent { return this.props.item.uploading; } + /** + * Check if this item has been successfully uploaded. + * Excludes items not uploaded in this request. + * + * @returns {Boolean} + */ + complete() { + // Uploading is complete if saved with a DB id + return this.uploading() && this.props.item.id > 0; + } + /** * Determine that this record is an image, and the thumbnail is smaller than the given thumbnail area * @@ -204,13 +215,15 @@ class GalleryItem extends SilverStripeComponent { if (!this.isImage() || (!this.exists() && !this.uploading())) { return false; } - const dimensions = this.props.item.dimensions; + const width = this.props.item.width; + const height = this.props.item.height; // Note: dimensions will be null if the back-end image is lost return ( - dimensions - && dimensions.height < CONSTANTS.THUMBNAIL_HEIGHT - && dimensions.width < CONSTANTS.THUMBNAIL_WIDTH + height + && width + && height < CONSTANTS.THUMBNAIL_HEIGHT + && width < CONSTANTS.THUMBNAIL_WIDTH ); } @@ -253,7 +266,7 @@ class GalleryItem extends SilverStripeComponent { if (this.hasError()) { this.props.onRemoveErroredUpload(this.props.item); - } else { + } else if (this.props.onCancelUpload) { this.props.onCancelUpload(this.props.item); } } @@ -273,7 +286,7 @@ class GalleryItem extends SilverStripeComponent { }, }; - if (!this.hasError() && this.uploading()) { + if (!this.hasError() && this.uploading() && !this.complete()) { progressBar = (
diff --git a/client/src/components/GalleryItem/tests/GalleryItem-test.js b/client/src/components/GalleryItem/tests/GalleryItem-test.js index 2c8cf80b1..0dd0f9d39 100644 --- a/client/src/components/GalleryItem/tests/GalleryItem-test.js +++ b/client/src/components/GalleryItem/tests/GalleryItem-test.js @@ -18,10 +18,8 @@ describe('GalleryItem', () => { onActivate: jest.genMockFunction(), handleDelete: jest.genMockFunction(), item: { - dimensions: { - width: 10, - height: 10, - }, + width: 10, + height: 10, exists: true, category: 'image', id: 1, @@ -239,10 +237,8 @@ describe('GalleryItem', () => { }); it('should return false if the dimensions are larger than the default thumbnail size', () => { - props.item.dimensions = { - width: 1000, - height: 1000, - }; + props.item.width = 1000; + props.item.height = 1000; expect(item.isImageSmallerThanThumbnail()).toBe(false); }); diff --git a/client/src/components/PreviewImageField/PreviewImageField.js b/client/src/components/PreviewImageField/PreviewImageField.js index 0d81753c8..1d55f4ea2 100644 --- a/client/src/components/PreviewImageField/PreviewImageField.js +++ b/client/src/components/PreviewImageField/PreviewImageField.js @@ -22,7 +22,11 @@ class PreviewImageField extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.data.url && nextProps.data.url !== this.props.data.url) { + // Check latest version to detect file save actions + if ( + (this.props.data.url && nextProps.data.url !== this.props.data.url) + || (this.props.data.version && nextProps.data.version !== this.props.data.version) + ) { this.props.actions.previewField.removeFile(this.props.id); } } @@ -321,6 +325,7 @@ PreviewImageField.propTypes = { onAutofill: PropTypes.func, data: PropTypes.shape({ parentid: PropTypes.number, + version: PropTypes.number, url: PropTypes.string, exists: PropTypes.bool, preview: PropTypes.string, diff --git a/client/src/components/UploadField/UploadFieldItem.js b/client/src/components/UploadField/UploadFieldItem.js index c806b0983..8433d70b2 100644 --- a/client/src/components/UploadField/UploadFieldItem.js +++ b/client/src/components/UploadField/UploadFieldItem.js @@ -153,13 +153,15 @@ class UploadFieldItem extends SilverStripeComponent { if (!this.isImage() || (!this.exists() && !this.uploading())) { return false; } - const dimensions = this.props.item.dimensions; + const width = this.props.item.width; + const height = this.props.item.height; // Note: dimensions will be null if the back-end image is lost return ( - dimensions - && dimensions.height < CONSTANTS.SMALL_THUMBNAIL_HEIGHT - && dimensions.width < CONSTANTS.SMALL_THUMBNAIL_WIDTH + height + && width + && height < CONSTANTS.SMALL_THUMBNAIL_HEIGHT + && width < CONSTANTS.SMALL_THUMBNAIL_WIDTH ); } diff --git a/client/src/containers/AssetAdmin/AssetAdmin.js b/client/src/containers/AssetAdmin/AssetAdmin.js index 784e08295..ae7f48137 100644 --- a/client/src/containers/AssetAdmin/AssetAdmin.js +++ b/client/src/containers/AssetAdmin/AssetAdmin.js @@ -1,15 +1,19 @@ import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; +import { bindActionCreators, compose } from 'redux'; import SilverStripeComponent from 'lib/SilverStripeComponent'; import backend from 'lib/Backend'; import i18n from 'i18n'; import * as galleryActions from 'state/gallery/GalleryActions'; import * as breadcrumbsActions from 'state/breadcrumbs/BreadcrumbsActions'; +import * as queuedFilesActions from 'state/queuedFiles/QueuedFilesActions'; import Editor from 'containers/Editor/Editor'; import Gallery from 'containers/Gallery/Gallery'; import Breadcrumb from 'components/Breadcrumb/Breadcrumb'; import Toolbar from 'components/Toolbar/Toolbar'; +import { graphql, withApollo } from 'react-apollo'; +import gql from 'graphql-tag'; +import { NetworkStatus } from 'apollo-client/queries/store'; class AssetAdmin extends SilverStripeComponent { @@ -27,6 +31,8 @@ class AssetAdmin extends SilverStripeComponent { this.handleFolderIcon = this.handleFolderIcon.bind(this); this.handleBrowse = this.handleBrowse.bind(this); this.handleViewChange = this.handleViewChange.bind(this); + this.handleUpload = this.handleUpload.bind(this); + this.handleCreateFolderSuccess = this.handleCreateFolderSuccess.bind(this); this.compare = this.compare.bind(this); } @@ -36,10 +42,7 @@ class AssetAdmin extends SilverStripeComponent { // Build API callers from the URLs provided in configuration. // In time, something like a GraphQL endpoint might be a better way to run. this.endpoints = { - createFolderApi: this.createEndpoint(config.createFolderEndpoint), - readFolderApi: this.createEndpoint(config.readFolderEndpoint, false), updateFolderApi: this.createEndpoint(config.updateFolderEndpoint), - deleteApi: this.createEndpoint(config.deleteEndpoint), historyApi: this.createEndpoint(config.historyEndpoint), }; } @@ -124,7 +127,7 @@ class AssetAdmin extends SilverStripeComponent { handleBackButtonClick(event) { event.preventDefault(); if (this.props.folder) { - this.handleOpenFolder(this.props.folder.parentID || 0); + this.handleOpenFolder(this.props.folder.parentId || 0); } else { this.handleOpenFolder(0); } @@ -232,9 +235,9 @@ class AssetAdmin extends SilverStripeComponent { } return promise .then((response) => { - if (response && response.record) { - this.props.actions.gallery.loadFile(this.props.fileId, response.record); - } + // TODO Update GraphQL store with new model, + // see https://github.com/silverstripe/silverstripe-graphql/issues/14 + this.props.refetch(); return response; }); @@ -262,21 +265,59 @@ class AssetAdmin extends SilverStripeComponent { * @param {number} fileId */ handleDelete(fileId) { - let file = this.props.files.find((item) => item.id === fileId); + // TODO Refactor "queued files" into separate visual area and remove coupling here + const allFiles = [...this.props.files, ...this.props.queuedFiles.items]; + let file = allFiles.find((item) => item.id === fileId); if (!file && this.props.folder && this.props.folder.id === fileId) { file = this.props.folder; } - // eslint-disable-next-line no-alert - if (confirm(i18n._t('AssetAdmin.CONFIRMDELETE'))) { - this.props.actions.gallery.deleteItems(this.endpoints.deleteApi, [fileId]) - .then(() => { - // redirect to open parent folder if the file/folder is open and on screen to close it - if (file) { - this.handleBrowse((file.parent) ? file.parent.id : 0); - } - }); + if (!file) { + throw new Error(`File selected for deletion cannot be found: ${fileId}`); } + + const dataId = this.props.client.dataId({ + __typename: file.__typename, + id: file.id, + }); + + return this.props.mutate({ + mutation: 'DeleteFile', + variables: { + id: file.id, + }, + resultBehaviors: [ + { + type: 'DELETE', + dataId, + }, + ], + }).then(() => { + this.props.actions.gallery.deselectFiles([file.id]); + + // If the file was just uploaded, it doesn't exist in the Apollo store, + // and has to be removed from the queue instead. + if (file.queuedId) { + this.props.actions.queuedFiles.removeQueuedFile(file.queuedId); + } + + // redirect to open parent folder if the file/folder is open and on screen to close it + this.handleBrowse((file.parent) ? file.parent.id : 0); + }); + } + + handleUpload() { + // TODO Update GraphQL store with new model, + // see https://github.com/silverstripe/silverstripe-graphql/issues/14 + + // TODO Maybe we dont need to immediately refetch? (Damian 19-12-2016) + // this.props.refetch(); + } + + handleCreateFolderSuccess() { + // TODO Update GraphQL store with new model, + // see https://github.com/silverstripe/silverstripe-graphql/issues/14 + this.props.refetch(); } /** @@ -297,26 +338,29 @@ class AssetAdmin extends SilverStripeComponent { return ( ); } @@ -346,7 +390,7 @@ class AssetAdmin extends SilverStripeComponent { break; } - if (!this.props.fileId || this.props.files.length === 0) { + if (!this.props.fileId) { return null; } @@ -375,7 +419,7 @@ class AssetAdmin extends SilverStripeComponent { {this.renderGallery()} {this.renderEditor()}
- {this.props.type === 'insert' && this.props.loading && + {this.props.type !== 'admin' && this.props.loading && [
,
] } @@ -385,6 +429,7 @@ class AssetAdmin extends SilverStripeComponent { } AssetAdmin.propTypes = { + mutate: React.PropTypes.func.isRequired, dialog: PropTypes.bool, sectionConfig: PropTypes.shape({ url: PropTypes.string, @@ -403,32 +448,44 @@ AssetAdmin.propTypes = { onSubmitEditor: PropTypes.func, type: PropTypes.oneOf(['insert', 'select', 'admin']), files: PropTypes.array, + queuedFiles: PropTypes.shape({ + items: PropTypes.array.isRequired, + }), + filesTotalCount: PropTypes.number, folder: PropTypes.shape({ id: PropTypes.number, title: PropTypes.string, parents: PropTypes.array, - parentID: PropTypes.number, + parentId: PropTypes.number, canView: PropTypes.bool, canEdit: PropTypes.bool, }), + loading: PropTypes.bool, }; AssetAdmin.defaultProps = { type: 'admin', + query: { + sort: '', + limit: null, // set to config default in mapStateToProps + page: 0, + }, }; -function mapStateToProps(state) { - const { - loading, - folder, - files, - } = state.assetAdmin.gallery; - +function mapStateToProps(state, ownProps) { return { - loading, - files, - folder, securityId: state.config.SecurityID, + // TODO Refactor "queued files" into separate visual area and remove coupling here + queuedFiles: state.assetAdmin.queuedFiles, + query: Object.assign( + {}, + { + limit: ownProps.sectionConfig.limit, + sort: '', + page: 0, + }, + ownProps.query + ), }; } @@ -437,10 +494,102 @@ function mapDispatchToProps(dispatch) { actions: { gallery: bindActionCreators(galleryActions, dispatch), breadcrumbsActions: bindActionCreators(breadcrumbsActions, dispatch), + // TODO Refactor "queued files" into separate visual area and remove coupling here + queuedFiles: bindActionCreators(queuedFilesActions, dispatch), }, }; } +// GraphQL Query +// TODO Resolve fragment duplication with Gallery +const readFilesQuery = gql` + query ReadFiles($id:ID!, $limit:Int!, $offset:Int!, $sortByChildren:[ChildrenSortInputType]) { + readFiles(id: $id) { + pageInfo { + totalCount + } + edges { + node { + ...FileInterfaceFields + ...FileFields + ...on Folder { + children(limit:$limit, offset:$offset, sortBy:$sortByChildren) { + pageInfo { + totalCount + } + edges { + node { + ...FileInterfaceFields + ...FileFields + } + } + } + parents { + id + title + } + } + } + } + } + } + ${Gallery.fragments.fileInterface} + ${Gallery.fragments.file} +`; +const updateFileMutation = gql`mutation UpdateFile($id:ID!, $file:FileInput!) { + updateFile(id: $id, file: $file) { + id + } +}`; +const deleteFileMutation = gql`mutation DeleteFile($id:ID!) { + deleteFile(id: $id) +}`; + export { AssetAdmin }; -export default connect(mapStateToProps, mapDispatchToProps)(AssetAdmin); +export default compose( + connect(mapStateToProps, mapDispatchToProps), + graphql(readFilesQuery, { + options({ sectionConfig, folderId, query: { limit, page, sort } }) { + const [sortField, sortDir] = sort.split(','); + return { + variables: { + id: folderId, + limit: limit || sectionConfig.limit, + offset: (page || 0) * (limit || sectionConfig.limit), + sortByChildren: (sortField && sortDir) + ? [{ field: sortField, direction: sortDir.toUpperCase() }] + : undefined, + }, + }; + }, + props({ data: { networkStatus: currentNetworkStatus, refetch, readFiles } }) { + // Uses same query as search and file list to return a single result (the containing folder) + const folder = (readFiles && readFiles.edges[0]) ? readFiles.edges[0].node : null; + const files = (folder && folder.children) + // Filter nodes because the DELETE resultBehaviour doesn't delete the edge, only the node + ? folder.children.edges.map((edge) => edge.node).filter((file) => file) + : []; + const filesTotalCount = (folder && folder.children) ? folder.children.pageInfo.totalCount : 0; + + // Only set to loading if a network request is in progress. + // TODO Use built-in 'loading' indicator once it's set to true on setVariables() calls. + // TODO Respect optimistic loading results. We can't check for presence of readFiles object, + // since Apollo sends through the previous result before optimistically setting the new result. + const loading = + currentNetworkStatus !== NetworkStatus.ready + && currentNetworkStatus !== NetworkStatus.error; + + return { + loading, + refetch, + folder, + files, + filesTotalCount, + }; + }, + }), + graphql(updateFileMutation), + graphql(deleteFileMutation), + (component) => withApollo(component) +)(AssetAdmin); diff --git a/client/src/containers/AssetAdmin/AssetAdminRouter.js b/client/src/containers/AssetAdmin/AssetAdminRouter.js index 0f59dbb08..778c1cd63 100644 --- a/client/src/containers/AssetAdmin/AssetAdminRouter.js +++ b/client/src/containers/AssetAdmin/AssetAdminRouter.js @@ -82,6 +82,7 @@ class AssetAdminRouter extends Component { AssetAdminRouter.propTypes = { sectionConfig: PropTypes.shape({ url: PropTypes.string, + limit: PropTypes.number, form: PropTypes.object, }), location: PropTypes.shape({ diff --git a/client/src/containers/AssetAdmin/tests/AssetAdmin-test.js b/client/src/containers/AssetAdmin/tests/AssetAdmin-test.js new file mode 100644 index 000000000..acd2579a5 --- /dev/null +++ b/client/src/containers/AssetAdmin/tests/AssetAdmin-test.js @@ -0,0 +1,219 @@ +/* global jest, describe, it, pit, expect, beforeEach, jasmine */ + +jest.unmock('react'); +jest.unmock('react-dom'); +jest.unmock('react-redux'); +jest.unmock('react-addons-test-utils'); +jest.unmock('../AssetAdmin'); +jest.mock('containers/Editor/Editor'); + +import React from 'react'; +import ReactTestUtils from 'react-addons-test-utils'; +import { AssetAdmin } from '../AssetAdmin'; + +const graphql = require('react-apollo').graphql; + +function getMockFile(id) { + return { + id, + __typename: 'File', + }; +} + +describe('AssetAdmin', () => { + let props = null; + + beforeEach(() => { + props = { + client: { + dataId: jest.fn(), + }, + mutate: jest.genMockFunction() + .mockReturnValue(Promise.resolve()), + dialog: true, + sectionConfig: { + url: '', + limit: 10, + createFileEndpoint: { + url: '', + }, + form: { + fileEditForm: { + schemaUrl: '', + }, + }, + }, + fileId: null, + folderId: null, + getUrl: jest.fn(), + query: { + sort: '', + limit: 10, + page: 0, + }, + onSubmitEditor: jest.fn(), + type: 'admin', + files: [], + queuedFiles: { + items: [], + }, + filesTotalCount: 20, + folder: { + id: 0, + title: '', + parents: [], + parentId: 0, + canView: true, + canEdit: true, + }, + actions: { + gallery: {}, + breadcrumbsActions: {}, + queuedFiles: { + addQueuedFile: () => null, + failUpload: () => null, + purgeUploadQueue: () => null, + removeQueuedFile: () => null, + succeedUpload: () => null, + }, + }, + }; + }); + + describe('handleDelete', () => { + let component = null; + + beforeEach(() => { + props.files = [ + getMockFile(1), + ]; + props.queuedFiles = { + items: [ + Object.assign({}, getMockFile(2), { queuedId: 2 }), + ], + }; + component = ReactTestUtils.renderIntoDocument(); + }); + + it('should delete a file', () => { + const id = props.files[0].id; + component.handleDelete(id); + + expect(props.mutate.mock.calls.length).toBe(1); + const callArgs = props.mutate.mock.calls[0]; + expect(callArgs[0].mutation).toBe('DeleteFile'); + expect(callArgs[0].variables).toEqual({ id }); + }); + + it('should delete a queued file', () => { + const id = props.queuedFiles.items[0].id; + component.handleDelete(id); + + expect(props.mutate.mock.calls.length).toBe(1); + const callArgs = props.mutate.mock.calls[0]; + expect(callArgs[0].mutation).toBe('DeleteFile'); + expect(callArgs[0].variables).toEqual({ id }); + }); + + // TODO Fix promise returns in jest + // pit('should deselect files after a delete', () => { + // const id = props.files[0].id; + // props.actions.gallery.deselectFiles = jest.genMockFunction(); + // props.mutate.mockReturnValue(Promise.resolve()); + // return component.handleDelete(id).then(() => { + // expect(props.actions.gallery.deselectFiles.mock.calls.length) + // .toBe(1); + // expect(props.actions.gallery.deselectFiles.mock.calls[0]) + // .toEqual([id]); + // }); + // }); + + // TODO Fix promise returns in jest + // pit('should remove the file from the queued files list', () => { + // const id = props.queuedFiles.items[0].id; + // props.actions.queuedFiles.removeQueuedFile = jest.genMockFunction(); + // return component.handleDelete(id).then(() => { + // expect(props.actions.queuedFiles.removeQueuedFile.mock.calls.length) + // .toBe(1); + // expect(props.actions.queuedFiles.removeQueuedFile.mock.calls[0]) + // .toEqual([props.queuedFiles.items[0].queuedId]); + // }); + // }); + }); + + describe('graphql', () => { + let graphqlData = null; + let child1 = null; + let child2 = null; + let folder = null; + + beforeEach(() => { + child1 = { node: { id: 2 } }; + child2 = { node: { id: 3 } }; + folder = { + id: 1, + children: { + pageInfo: { totalCount: 2 }, + edges: [child1, child2], + }, + }; + graphqlData = { + data: { + readFiles: { + pageInfo: { totalCount: 1 }, + edges: [ + { node: folder }, + ], + }, + }, + }; + }); + + it('should map the readFiles data to props', () => { + ReactTestUtils.renderIntoDocument(); + + const graphqlOpts = graphql.mock.calls[0][1]; + const graphqlProps = graphqlOpts.props(graphqlData); + + expect(graphqlProps.files).toContain(child1.node); + expect(graphqlProps.files).toContain(child2.node); + expect(graphqlProps.filesTotalCount).toBe(2); + }); + + it('should calculate pagination info in options', () => { + const ownProps = { + sectionConfig: {}, + folderId: 1, + query: { + limit: 10, + page: 2, + sort: 'title desc', + }, + }; + const graphqlOpts = graphql.mock.calls[0][1]; + const vars = graphqlOpts.options(ownProps); + + expect(vars.variables.limit).toBe(10); + expect(vars.variables.offset).toBe(10 * 2); + }); + + it('should calculate pagination info on defaults in options', () => { + const ownProps = { + sectionConfig: { + limit: 10, + }, + folderId: 1, + query: { + limit: null, + page: 2, + sort: 'title desc', + }, + }; + const graphqlOpts = graphql.mock.calls[0][1]; + const vars = graphqlOpts.options(ownProps); + + expect(vars.variables.limit).toBe(10); + expect(vars.variables.offset).toBe(10 * 2); + }); + }); +}); diff --git a/client/src/containers/Editor/Editor.js b/client/src/containers/Editor/Editor.js index 8ec1cc2ca..bd11486bf 100644 --- a/client/src/containers/Editor/Editor.js +++ b/client/src/containers/Editor/Editor.js @@ -31,7 +31,10 @@ class Editor extends Component { } if (name === 'action_delete') { - this.props.onDelete(data.ID); + // eslint-disable-next-line no-alert + if (confirm(i18n._t('AssetAdmin.CONFIRMDELETE'))) { + this.props.onDelete(data.ID); + } event.preventDefault(); return; } diff --git a/client/src/containers/Gallery/Gallery.js b/client/src/containers/Gallery/Gallery.js index 663aecebc..5e0032899 100644 --- a/client/src/containers/Gallery/Gallery.js +++ b/client/src/containers/Gallery/Gallery.js @@ -6,7 +6,7 @@ import ReactDOM from 'react-dom'; import ReactTestUtils from 'react-addons-test-utils'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; +import { bindActionCreators, compose } from 'redux'; import AssetDropzone from 'components/AssetDropzone/AssetDropzone'; import BulkActions from 'components/BulkActions/BulkActions'; import ThumbnailView from 'containers/ThumbnailView/ThumbnailView'; @@ -14,11 +14,15 @@ import TableView from 'containers/TableView/TableView'; import CONSTANTS from 'constants/index'; import * as galleryActions from 'state/gallery/GalleryActions'; import * as queuedFilesActions from 'state/queuedFiles/QueuedFilesActions'; +import { graphql, withApollo } from 'react-apollo'; +import gql from 'graphql-tag'; /** * List of sorters for tile view, required here because it's rendered outside the tile view * component * + * @todo Use lowercase identifiers once we can map them in the silverstripe/graphql module + * * @type {array} sorters */ const sorters = [ @@ -33,12 +37,12 @@ const sorters = [ label: i18n._t('AssetAdmin.FILTER_TITLE_DESC', 'title z-a'), }, { - field: 'created', + field: 'lastEdited', direction: 'desc', label: i18n._t('AssetAdmin.FILTER_DATE_DESC', 'newest'), }, { - field: 'created', + field: 'lastEdited', direction: 'asc', label: i18n._t('AssetAdmin.FILTER_DATE_ASC', 'oldest'), }, @@ -65,12 +69,10 @@ class Gallery extends Component { this.handleFailedUpload = this.handleFailedUpload.bind(this); this.handleCreateFolder = this.handleCreateFolder.bind(this); this.handleViewChange = this.handleViewChange.bind(this); - this.renderNoItemsNotice = this.renderNoItemsNotice.bind(this); } componentDidMount() { - // load contents when mounted - this.refreshFolderIfNeeded(null, this.props); + this.initSortDropdown(); } componentWillReceiveProps(nextProps) { @@ -81,33 +83,19 @@ class Gallery extends Component { $select.off('change'); } - // check if contents need a refresh - this.refreshFolderIfNeeded(this.props, nextProps); - } - - componentDidUpdate() { - // turn on chosen if required - if (this.props.view === 'tile') { - const $select = this.getSortElement(); - - // We opt-out of letting the CMS handle Chosen because it doesn't - // re-apply the behaviour correctly. - // So after the gallery has been rendered we apply Chosen. - $select.chosen({ - allow_single_deselect: true, - disable_search_threshold: 20, - }); - - // Chosen stops the change event from reaching React so we have to simulate a click. - $select.on('change', () => ReactTestUtils.Simulate.click($select.find(':selected')[0])); + // If props.files has changed, flush any uploaded files. + // The render() logic will merge queuedFiles into the props.files array + // until this is called, leaving completed uploads temporarily in the current view, + // even if they're technically not part of props.files. + if (this.compareFiles(this.props.files, nextProps.files)) { + nextProps.actions.queuedFiles.purgeUploadQueue(); } this.checkLoadingIndicator(); } - componentWillUnmount() { - // clear existing folder content, so behaviour of component is predictable for the Modal - this.props.actions.gallery.unloadFolderContents(); + componentDidUpdate() { + this.initSortDropdown(); } /** @@ -126,6 +114,9 @@ class Gallery extends Component { */ checkLoadingIndicator() { const $sectionWrapper = $('.cms-content.AssetAdmin'); + if (!$sectionWrapper.length) { + return; + } if (this.props.loading) { $sectionWrapper.addClass('loading'); @@ -135,37 +126,46 @@ class Gallery extends Component { } /** - * Checks if key properties were changed and if they have then start a request to get new data - * from the server. - * Properties are: - * - folderId - * - limit - * - page - * - sort + * Compare two lists to see if equal * - * @param {object} prevProps - * @param {object} nextProps + * @param {Array} left + * @param {Array} right + * @return {Boolean} */ - refreshFolderIfNeeded(prevProps, nextProps) { - if (!prevProps - || nextProps.folderId !== prevProps.folderId - || nextProps.limit !== prevProps.limit - || nextProps.page !== prevProps.page - || nextProps.sort !== prevProps.sort - ) { - // TODO move this to AssetAdmin, anti-pattern for child to set props/state for parent - this.props.actions.gallery.deselectFiles(); - this.props.actions.gallery.loadFolderContents( - nextProps.readFolderApi, - nextProps.folderId, - nextProps.limit, - nextProps.page, - nextProps.sort - ); + compareFiles(left, right) { + if ((left && !right) || (!left && right)) { + return true; } + if (left.length !== right.length) { + return true; + } + for (let i = 0; i < left.length; i++) { + if (left[i].id !== right[i].id) { + return true; + } + } + return false; } - /** + initSortDropdown() { + // turn on chosen if required + if (this.props.view === 'tile') { + const $select = this.getSortElement(); + + // We opt-out of letting the CMS handle Chosen because it doesn't + // re-apply the behaviour correctly. + // So after the gallery has been rendered we apply Chosen. + $select.chosen({ + allow_single_deselect: true, + disable_search_threshold: 20, + }); + + // Chosen stops the change event from reaching React so we have to simulate a click. + $select.on('change', () => ReactTestUtils.Simulate.click($select.find(':selected')[0])); + } + } + + /** * Handler for when the user changes the sort order * * @param {string} value @@ -243,13 +243,35 @@ class Gallery extends Component { * @param {Event} event */ handleCreateFolder(event) { - const folderName = this.promptFolderName(); - if (folderName !== null) { - this.props.actions.gallery.createFolder(this.props.createFolderApi, this.props.folderId, folderName) - .then(data => { - this.refreshFolderIfNeeded(null, this.props); - return data; - }); + const name = this.promptFolderName(); + const parentId = parseInt(this.props.folder.id, 10); + if (name) { + this.props.mutate({ + mutation: 'CreateFolder', + variables: { + folder: { + parentId, + name, + }, + }, + }).then((data) => { + if (this.props.onCreateFolderSuccess) { + this.props.onCreateFolderSuccess(data); + } + }); + // TODO Figure out how to use fields with arguments in store path + // const dataId = this.props.client.dataId({ + // __typename: 'Folder', + // id: parentId, + // }); + // resultBehaviors: [ + // { + // type: 'ARRAY_INSERT', + // resultPath: ['createFolder'], + // storePath: [dataId, 'children({"limit:15,"offset":0})'], + // where: 'PREPEND', + // }, + // ], } event.preventDefault(); } @@ -269,8 +291,13 @@ class Gallery extends Component { return; } - this.props.actions.queuedFiles.removeQueuedFile(fileXhr._queuedId); - this.props.actions.gallery.addFiles(json, this.props.count + 1); + this.props.actions.queuedFiles.succeedUpload(fileXhr._queuedId, json[0]); + + // TODO Update GraphQL store with new model, + // see https://github.com/silverstripe/silverstripe-graphql/issues/14 + if (this.props.onSuccessfulUpload) { + this.props.onSuccessfulUpload(json); + } // redirect to open the last uploaded file for 'insert/select modal' type only if (this.props.type !== 'admin' @@ -366,7 +393,7 @@ class Gallery extends Component { */ handleBackClick(event) { event.preventDefault(); - this.props.onOpenFolder(this.props.folder.parentID); + this.props.onOpenFolder(this.props.folder.parentId); } /** @@ -506,7 +533,7 @@ class Gallery extends Component { 'btn--icon-large', 'gallery__back', ].join(' '); - if (this.props.folder.parentID !== null) { + if (this.props.folder.parentId !== null) { return (