Added project settings allowing setup + editing task types.
- Attract added to Project Settings screen - setting up project for Attract - editing shot/asset task types To do: add checks that the user is allowed to use Attract in the first place.
This commit is contained in:
@@ -178,3 +178,23 @@ function setHeaderCellsWidth(tableHeaderRowOriginal, tableHeaderRowFixed) {
|
||||
return table_header.eq(i).width();
|
||||
});
|
||||
}
|
||||
|
||||
/* Returns a more-or-less reasonable message given an error response object. */
|
||||
function xhrErrorResponseMessage(err) {
|
||||
if (typeof err.responseJSON == 'undefined')
|
||||
return err.statusText;
|
||||
|
||||
if (typeof err.responseJSON._error != 'undefined' && typeof err.responseJSON._error.message != 'undefined')
|
||||
return err.responseJSON._error.message;
|
||||
|
||||
if (typeof err.responseJSON._message != 'undefined')
|
||||
return err.responseJSON._message
|
||||
|
||||
return err.statusText;
|
||||
}
|
||||
|
||||
function xhrErrorResponseElement(err, prefix) {
|
||||
msg = xhrErrorResponseMessage(err);
|
||||
return $('<span>')
|
||||
.text(prefix + msg);
|
||||
}
|
||||
|
23
src/templates/attract/project_settings/attract_layout.jade
Normal file
23
src/templates/attract/project_settings/attract_layout.jade
Normal file
@@ -0,0 +1,23 @@
|
||||
| {% extends 'projects/edit_layout.html' %}
|
||||
| {% set title = 'attract' %}
|
||||
| {% block page_title %}Attract settings for {{ project.name }}{% endblock %}
|
||||
|
||||
| {% block head %}
|
||||
script(src="{{ url_for('static_attract', filename='assets/js/generated/tutti.min.js') }}")
|
||||
| {% endblock %}
|
||||
|
||||
| {% block project_context_header %}
|
||||
span#project-edit-title
|
||||
| {{ self.page_title() }}
|
||||
| {% endblock %}
|
||||
|
||||
| {% block project_context %}
|
||||
#node-edit-container
|
||||
| {% block attract_container %}
|
||||
| {% endblock attract_container %}
|
||||
|
||||
.settings-footer
|
||||
p
|
||||
| New to Attract?
|
||||
| Sorry, we don't have documentation yet.
|
||||
| {% endblock project_context %}
|
26
src/templates/attract/project_settings/offer_setup.jade
Normal file
26
src/templates/attract/project_settings/offer_setup.jade
Normal file
@@ -0,0 +1,26 @@
|
||||
| {% extends 'attract/project_settings/attract_layout.html' %}
|
||||
|
||||
| {% block attract_container %}
|
||||
#node-edit-form
|
||||
p This project is not setup for Attract (yet!)
|
||||
p
|
||||
button.btn.btn-success(onclick='setupForAttract()') Setup Project for Attract
|
||||
|
||||
| {% endblock attract_container %}
|
||||
|
||||
| {% block footer_scripts %}
|
||||
script.
|
||||
function setupForAttract() {
|
||||
$.ajax({
|
||||
url: '{{ url_for( "attract.setup_for_attract", project_url=project.url) }}',
|
||||
method: 'POST',
|
||||
})
|
||||
.done(function() {
|
||||
window.location.reload();
|
||||
})
|
||||
.fail(function(err) {
|
||||
var err_elt = xhrErrorResponseElement(err, 'Error setting up your project: ');
|
||||
toastr.error(err_elt);
|
||||
});
|
||||
}
|
||||
| {% endblock %}
|
58
src/templates/attract/project_settings/settings.jade
Normal file
58
src/templates/attract/project_settings/settings.jade
Normal file
@@ -0,0 +1,58 @@
|
||||
| {% extends 'attract/project_settings/attract_layout.html' %}
|
||||
|
||||
| {% block attract_container %}
|
||||
#node-edit-form
|
||||
|
||||
h3 Shot-related task types
|
||||
p Here you can edit the task columns shown in this project's
|
||||
=' '
|
||||
a(href="{{ url_for('attract.shots.perproject.index', project_url=project['url']) }}") shot list
|
||||
='.'
|
||||
|
||||
form(onsubmit="save(this, '{{ url_for('attract.save_task_types', project_url=project['url'], node_type_name=shot_node_type_name) }}'); return false;")
|
||||
.input-group
|
||||
textarea(
|
||||
name="task_types",
|
||||
type="text",
|
||||
rows="{{ shot_task_types|count + 1 }}",
|
||||
placeholder='Task types, one per line') {{ '\n'.join(shot_task_types) }}
|
||||
.input-group
|
||||
button.btn.btn-success.btn-block(type='submit')
|
||||
i.pi-check
|
||||
| Save Shot task types
|
||||
|
||||
h3 Asset-related task types
|
||||
p Here you can edit the task columns shown in this project's
|
||||
=' '
|
||||
a(href="{{ url_for('attract.assets.perproject.index', project_url=project['url']) }}") asset list
|
||||
='.'
|
||||
|
||||
form(onsubmit="save(this, '{{ url_for('attract.save_task_types', project_url=project['url'], node_type_name=asset_node_type_name) }}'); return false;")
|
||||
.input-group
|
||||
textarea(
|
||||
name="task_types",
|
||||
type="text",
|
||||
rows="{{ asset_task_types|count + 1 }}",
|
||||
placeholder='Task types, one per line') {{ '\n'.join(asset_task_types) }}
|
||||
.input-group
|
||||
button.btn.btn-success.btn-block(type='submit')
|
||||
i.pi-check
|
||||
| Save Asset task types
|
||||
|
||||
| {% endblock %}
|
||||
| {% block footer_scripts %}
|
||||
script.
|
||||
function save(form, url) {
|
||||
var $input = $(form).find('*[name="task_types"]');
|
||||
var task_types = $input.val();
|
||||
$.post(url, {'task_types': task_types})
|
||||
.done(function(xhr) {
|
||||
$input.val(xhr.task_types.join('\n'));
|
||||
$input.attr('rows', xhr.task_types.length + 1);
|
||||
toastr.success('Task types saved');
|
||||
})
|
||||
.fail(function(err) {
|
||||
toastr.error(xhrErrorResponseElement(err, 'Error saving task types: '));
|
||||
});
|
||||
}
|
||||
| {% endblock %}
|
Reference in New Issue
Block a user