diff --git a/src/asset_manager/config/config.js b/src/asset_manager/config/config.js
index 1cd564537..866c83fbc 100644
--- a/src/asset_manager/config/config.js
+++ b/src/asset_manager/config/config.js
@@ -97,5 +97,8 @@ export default {
// var stopUpload = true;
// if(stopUpload) return false;
// }
- beforeUpload: null
+ beforeUpload: null,
+
+ // Toggles visiblity of assets url input
+ showUrlInput: true
};
diff --git a/src/asset_manager/view/AssetsView.js b/src/asset_manager/view/AssetsView.js
index ae098d451..a7fbd7b53 100644
--- a/src/asset_manager/view/AssetsView.js
+++ b/src/asset_manager/view/AssetsView.js
@@ -6,17 +6,24 @@ export default Backbone.View.extend({
},
template({ pfx, ppfx, em, ...view }) {
+ let form = '';
+ if (this.config.showUrlInput) {
+ form = `
+
@@ -46,7 +53,7 @@ export default Backbone.View.extend({
handleSubmit(e) {
e.preventDefault();
const input = this.getAddInput();
- const url = input.value.trim();
+ const url = input && input.value.trim();
const handleAdd = this.config.handleAdd;
if (!url) {
diff --git a/test/specs/asset_manager/view/AssetsView.js b/test/specs/asset_manager/view/AssetsView.js
index 328bbc188..853e8edb2 100644
--- a/test/specs/asset_manager/view/AssetsView.js
+++ b/test/specs/asset_manager/view/AssetsView.js
@@ -14,7 +14,6 @@ describe('AssetsView', () => {
globalCollection: new Assets([]),
fu: new FileUploader({})
});
- obj = obj;
document.body.innerHTML = '
';
obj.render();
document.body.querySelector('#fixtures').appendChild(obj.el);
@@ -68,16 +67,64 @@ describe('AssetsView', () => {
expect(obj.getAssetsEl()).toBeTruthy();
});
- test('Returns not empty url input', () => {
- expect(obj.getAddInput()).toBeTruthy();
+ describe('Assets input is enabled', () => {
+ var obj;
+ var coll;
+ coll = new Assets([]);
+
+ beforeEach(() => {
+ var config = {
+ showUrlInput: true
+ };
+
+ obj = new AssetsView({
+ config: config,
+ collection: coll,
+ globalCollection: new Assets([]),
+ fu: new FileUploader({})
+ });
+ document.body.innerHTML = '
';
+ obj.render();
+ document.body.querySelector('#fixtures').appendChild(obj.el);
+ });
+
+ test('Returns not empty url input', () => {
+ expect(obj.getAddInput()).toBeTruthy();
+ });
+
+ test('Add image asset from input string', () => {
+ obj.getAddInput().value = 'test';
+ obj.handleSubmit({
+ preventDefault() {}
+ });
+ var asset = obj.options.globalCollection.at(0);
+ expect(asset.get('src')).toEqual('test');
+ });
});
- test('Add image asset from input string', () => {
- obj.getAddInput().value = 'test';
- obj.handleSubmit({
- preventDefault() {}
+ describe('Assets inputs is disabled', () => {
+ var obj;
+ var coll;
+
+ beforeEach(() => {
+ var config = {
+ showUrlInput: false
+ };
+
+ coll = new Assets([]);
+ obj = new AssetsView({
+ config: config,
+ collection: coll,
+ globalCollection: new Assets([]),
+ fu: new FileUploader({})
+ });
+ document.body.innerHTML = '
';
+ obj.render();
+ document.body.querySelector('#fixtures').appendChild(obj.el);
+ });
+
+ test('No presence of url input', () => {
+ expect(obj.getAddInput()).toBeFalsy();
});
- var asset = obj.options.globalCollection.at(0);
- expect(asset.get('src')).toEqual('test');
});
});