-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't show share tab when selected workflow doesn't allow it. #3138
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ engines: | |
config: | ||
extensions: | ||
- .es6 | ||
ignore_warnings: true | ||
fixme: | ||
enabled: false | ||
rubocop: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,11 @@ | |
Sufia = { | ||
initialize: function () { | ||
this.autocomplete(); | ||
this.saveWorkControl(); | ||
this.saveWorkFixed(); | ||
this.popovers(); | ||
this.permissions(); | ||
this.notifications(); | ||
this.transfers(); | ||
this.relationshipsTable(); | ||
this.editor(); | ||
this.fileManager(); | ||
this.selectWorkType(); | ||
this.datatable(); | ||
|
@@ -40,16 +38,14 @@ Sufia = { | |
autocomplete.setup(); | ||
}, | ||
|
||
saveWorkControl: function () { | ||
var sw = require('sufia/save_work/save_work_control'); | ||
var control = new sw.SaveWorkControl($("#form-progress")) | ||
editor: function () { | ||
var element = $("[data-behavior='work-form']") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
if (element.length > 0) { | ||
var Editor = require('sufia/editor'); | ||
new Editor(element) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
} | ||
}, | ||
|
||
saveWorkFixed: function () { | ||
// Setting test to false to skip native and go right to polyfill | ||
FixedSticky.tests.sticky = false; | ||
$('#savewidget').fixedsticky(); | ||
}, | ||
|
||
// initialize popover helpers | ||
popovers: function () { | ||
|
@@ -82,13 +78,6 @@ Sufia = { | |
$("#proxy_deposit_request_transfer_to").userSearch(); | ||
}, | ||
|
||
relationshipsTable: function () { | ||
var rel = require('sufia/relationships/table'); | ||
$('table.relationships-ajax-enabled').each(function () { | ||
new rel.RelationshipsTable($(this)); | ||
}); | ||
}, | ||
|
||
selectWorkType: function () { | ||
var selectWork = require('sufia/select_work_type'); | ||
$("[data-behavior=select-work]").each(function () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
import Location from 'sufia/autocomplete/location' | ||
import Subject from 'sufia/autocomplete/subject' | ||
import Language from 'sufia/autocomplete/language' | ||
import Work from 'sufia/autocomplete/work' | ||
|
||
|
||
export class Autocomplete { | ||
constructor() { | ||
} | ||
constructor() { | ||
} | ||
|
||
// This is the initial setup for the form. | ||
setup() { | ||
$('[data-autocomplete]').each((index, value) => { | ||
let selector = $(value) | ||
switch (selector.data('autocomplete')) { | ||
case "subject": | ||
this.autocompleteSubject(selector); | ||
break; | ||
case "language": | ||
this.autocompleteLanguage(selector); | ||
break; | ||
case "based_near": | ||
this.autocompleteLocation(selector); | ||
break; | ||
case "work": | ||
var user = selector.data('user'); | ||
var id = selector.data('id'); | ||
this.autocompleteWork(selector, user, id); | ||
break; | ||
} | ||
}); | ||
} | ||
// This is the initial setup for the form. | ||
setup() { | ||
$('[data-autocomplete]').each((index, value) => { | ||
let selector = $(value) | ||
switch (selector.data('autocomplete')) { | ||
case "subject": | ||
this.autocompleteSubject(selector); | ||
break; | ||
case "language": | ||
this.autocompleteLanguage(selector); | ||
break; | ||
case "based_near": | ||
this.autocompleteLocation(selector); | ||
break; | ||
case "work": | ||
var user = selector.data('user'); | ||
var id = selector.data('id'); | ||
this.autocompleteWork(selector, user, id); | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
// attach an auto complete based on the field | ||
fieldAdded(cloneElem) { | ||
var $cloneElem = $(cloneElem); | ||
// FIXME this code (comparing the id) depends on a bug. Each input has an id and | ||
// the id is duplicated when you press the plus button. This is not valid html. | ||
if (/_based_near$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLocation($cloneElem); | ||
} else if (/_language$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLanguage($cloneElem); | ||
} else if (/_subject$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteSubject($cloneElem); | ||
// attach an auto complete based on the field | ||
fieldAdded(cloneElem) { | ||
var $cloneElem = $(cloneElem); | ||
// FIXME this code (comparing the id) depends on a bug. Each input has an id and | ||
// the id is duplicated when you press the plus button. This is not valid html. | ||
if (/_based_near$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLocation($cloneElem); | ||
} else if (/_language$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLanguage($cloneElem); | ||
} else if (/_subject$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteSubject($cloneElem); | ||
} | ||
} | ||
} | ||
|
||
autocompleteLocation(field) { | ||
var loc = require('sufia/autocomplete/location'); | ||
new loc.Location(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteLocation(field) { | ||
new Location(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteSubject(field) { | ||
var subj = require('sufia/autocomplete/subject'); | ||
new subj.Subject(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteSubject(field) { | ||
new Subject(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteLanguage(field) { | ||
var lang = require('sufia/autocomplete/language'); | ||
new lang.Language(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteLanguage(field) { | ||
new Language(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteWork(field, user, id) { | ||
var work = require('sufia/autocomplete/work') | ||
new work.Work( | ||
field, | ||
field.data('autocomplete-url'), | ||
user, | ||
id | ||
) | ||
} | ||
autocompleteWork(field, user, id) { | ||
new Work( | ||
field, | ||
field.data('autocomplete-url'), | ||
user, | ||
id | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import RelationshipsTable from 'sufia/relationships/table' | ||
import SaveWorkControl from 'sufia/save_work/save_work_control' | ||
import AdminSetWidget from 'sufia/editor/admin_set_widget' | ||
|
||
export default class { | ||
constructor(element) { | ||
this.element = element | ||
this.adminSetWidget = new AdminSetWidget(element.find('select[id$="_admin_set_id"]')) | ||
this.sharingTabElement = $('#tab-share') | ||
|
||
this.sharingTab() | ||
this.relationshipsTable() | ||
this.saveWorkControl() | ||
this.saveWorkFixed() | ||
} | ||
|
||
// Display the sharing tab if they select an admin set that permits sharing | ||
sharingTab() { | ||
if(this.adminSetWidget) { | ||
console.log("admin set selected") | ||
this.adminSetWidget.on('change', (data) => this.sharingTabVisiblity(data)) | ||
this.sharingTabVisiblity(this.adminSetWidget.data()) | ||
} | ||
} | ||
|
||
sharingTabVisiblity(data) { | ||
console.log("Data " + data["sharing"]) | ||
if (data["sharing"]) | ||
this.sharingTabElement.removeClass('hidden') | ||
else | ||
this.sharingTabElement.addClass('hidden') | ||
} | ||
|
||
relationshipsTable() { | ||
new RelationshipsTable(this.element.find('table.relationships-ajax-enabled')) | ||
} | ||
|
||
saveWorkControl() { | ||
new SaveWorkControl(this.element.find("#form-progress"), this.adminSetWidget) | ||
} | ||
|
||
saveWorkFixed() { | ||
// Setting test to false to skip native and go right to polyfill | ||
FixedSticky.tests.sticky = false | ||
this.element.find('#savewidget').fixedsticky() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default class { | ||
// takes a jquery selector for a select field | ||
// create a custom change event with the data when it changes | ||
constructor(element) { | ||
this.changeHandlers = [] | ||
this.element = element | ||
element.on('change', (e) => { | ||
this.change(this.data()) | ||
}) | ||
} | ||
|
||
data() { | ||
return this.element.find(":selected").data() | ||
} | ||
|
||
on(eventName, handler) { | ||
switch (eventName) { | ||
case "change": | ||
return this.changeHandlers.push(handler); | ||
} | ||
} | ||
|
||
change(data) { | ||
for (let fn of this.changeHandlers) { | ||
setTimeout(function() { fn(data) }, 0); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.