mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Use backbone to display taskmanager front end
This commit is contained in:
18
www/scripts/tests/fixtures/admin/fields/dom
vendored
18
www/scripts/tests/fixtures/admin/fields/dom
vendored
@@ -1,18 +0,0 @@
|
||||
<div id="admin-field-app" class="container-fluid">
|
||||
{# sbas_id is saved in the dom and used to fetch right models and collections #}
|
||||
<input type="hidden" name="current_sbas_id" value="{{ sbas_id }}">
|
||||
<div class="row-fluid row-top">
|
||||
<div class="span4 save-block">
|
||||
{# set loading state, this will be removed once backbone application is fully loaded #}
|
||||
<img src="/skins/icons/loaderFFF.gif"/>
|
||||
{% trans %}Loading database documentary fields ...{% endtrans %}
|
||||
</div>
|
||||
<div class="span8">
|
||||
<div class="block-alert"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid row-bottom hidden">
|
||||
<div class="left-block span4"></div>
|
||||
<div class="right-block span8"></div>
|
||||
</div>
|
||||
</div>
|
265
www/scripts/tests/fixtures/admin/fields/templates
vendored
265
www/scripts/tests/fixtures/admin/fields/templates
vendored
@@ -1,265 +0,0 @@
|
||||
<script type="text/template" id="alert_template">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<%= msg %>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="save_template">
|
||||
<button type="button" class="btn btn-large btn-success save-all">
|
||||
<i class="icon-hdd icon-white"></i> {% trans %}Save all changes{% endtrans %}
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="modal_template">
|
||||
<div class="modal-body">
|
||||
<p><%= msg %></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" data-dismiss="modal" class="btn cancel">{% trans %}Close{% endtrans %}</button>
|
||||
<button type="button" class="btn btn-primary confirm">{% trans %}Ok{% endtrans %}</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="item_list_view_template">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="create-subview"></div>
|
||||
<div class="sidebar-search-block">
|
||||
<input class="input-block-level" type="text" id="live_search" placeholder="{% trans %}Live search{% endtrans %}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12 list-block">
|
||||
<ul id="collection-fields" class="unstyled"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="create_template">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="sidebar-add-block">
|
||||
<button type="button" class="btn btn-success btn-add-field"><i class="icon-plus icon-white"></i>{% trans %}Add new field{% endtrans %}</button>
|
||||
</div>
|
||||
<div class="well well-small add-field-block" style="display:none">
|
||||
<h3>{% trans %}Add a new field{% endtrans %}</h3>
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="new-name"">{% trans %}Label{% endtrans %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="new-name" class="input-block-level" placeholder="">
|
||||
<span class="help-block"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="new-source">{% trans %}Source{% endtrans %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="new-source" class="input-block-level" placeholder="">
|
||||
<span class="help-block"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input id="new-multivalued" type="checkbox">{% trans %}Multivalued{% endtrans %}
|
||||
</label>
|
||||
<button type="button" class="btn btn-success btn-submit-field"><i class="icon-ok icon-white"></i>{% trans %}Add{% endtrans %}</button>
|
||||
<button type="button" class="btn btn-cancel-field">{% trans %}Cancel{% endtrans %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="edit_template">
|
||||
<div class="edit-block">
|
||||
<table>
|
||||
<tr class="edit-order">
|
||||
<td>{% trans %}Order{% endtrans %}</td>
|
||||
<td><%= field.sorter %></td>
|
||||
<td><button type="button" class="btn btn-danger delete-field pull-right"><i class="icon-trash icon-white"></i>delete</button></td>
|
||||
</tr>
|
||||
<tr class="edit-name ">
|
||||
<td colspan="2" class="control-group <%= modelErrors && modelErrors.has('name') ? 'error' : '' %>">
|
||||
<input id="name" type="text" value="<%= field.name %>" class="input-block-level">
|
||||
<span class="help-block">
|
||||
<% if(modelErrors && modelErrors.get('name')) { %>
|
||||
<%= modelErrors.get('name').message %>
|
||||
<% } %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans %}Source{% endtrans %}</td>
|
||||
<td class="control-group <%= modelErrors && modelErrors.has('tag') ? 'error' : '' %>">
|
||||
<input id="tag" val="<%= field.tag %>" class="input-block-level"/>
|
||||
<span class="help-block">
|
||||
<% if(modelErrors && modelErrors.get('tag')) { %>
|
||||
<%= modelErrors.get('tag').message %>
|
||||
<% } %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans %}DCES{% endtrans %}</td>
|
||||
<td class="dc-fields-subview"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="dces-help-block info"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<% if(field.multi == true) { %>
|
||||
<i class='icon-ok'></i>
|
||||
<% } else { %>
|
||||
<i class='icon-remove'></i>
|
||||
<% } %> {% trans %}Multivalued{% endtrans %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="edit-form">
|
||||
<h4>{% trans %}Advanced field parameters{% endtrans %}</h4>
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="tbranch">{% trans %}Thesaurus branch{% endtrans %}</label></td>
|
||||
<td><input id="tbranch" type="text" value="<%= field.tbranch %>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="type">{% trans %}Type{% endtrans %}</label></td>
|
||||
<td>
|
||||
<select id="type">
|
||||
<option <%= field.type == '' ? 'selected' : '' %> value=""></option>
|
||||
<option <%= field.type == 'string' ? 'selected' : '' %> value="string">string</option>
|
||||
<option <%= field.type == 'text' ? 'selected' : '' %> value="text">text</option>
|
||||
<option <%= field.type == 'number' ? 'selected' : '' %> value="number">number</option>
|
||||
<option <%= field.type == 'date' ? 'selected' : '' %> value="date">date</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="vocabulary-type">{% trans %}Vocabulary type{% endtrans %}</label></td>
|
||||
<td>
|
||||
<select id="vocabulary-type">
|
||||
<option <%= field['vocabulary-type'] == null ? 'selected' : '' %> value=''></option>
|
||||
<% _.each(vocabularyTypes, function(vocab) { %>
|
||||
<option <%= field['vocabulary-type'] == vocab.type ? 'selected' : '' %> value="<%= vocab.type %>"><%= vocab.name %></option>
|
||||
<% }); %>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<% if(field['vocabulary-type'] != null && field['vocabulary-type'] != '') { %>
|
||||
<label for="vocabulary-restricted" class="checkbox">
|
||||
<input id="vocabulary-restricted" type="checkbox" <%= field["vocabulary-restricted"] ? "checked='checked'" : "" %> />
|
||||
{% trans %}Limited vocabulary{% endtrans %}
|
||||
</label>
|
||||
<% } %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<label for="business" class="checkbox">
|
||||
<input id="business" type="checkbox" <%= field.business ? "checked='checked'" : "" %> />
|
||||
{% trans %}Business Fields{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="separator">{% trans %}Separator{% endtrans %}</label></td>
|
||||
<td><input id="separator" type="text" value="<%= field.separator %>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h4>{% trans %}Display & action settings{% endtrans %}</h4>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="required" class="checkbox">
|
||||
<input id="required" type="checkbox" <%= field.required ? "checked='checked'" : "" %> />
|
||||
{% trans %}Mandatory{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="indexable" class="checkbox">
|
||||
<input id="indexable" type="checkbox" <%= field.indexable ? "checked='checked'" : "" %> />
|
||||
{% trans %}Indexable{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="readonly" class="checkbox">
|
||||
<input id="readonly" type="checkbox" <%= field.readonly ? "checked='checked'" : "" %> />
|
||||
{% trans %}Read-only{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="report" class="checkbox">
|
||||
<input id="report" type="checkbox" <%= field.report ? "checked='checked'" : "" %> />
|
||||
{% trans %}Report{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="thumbtitle">{% trans %}Display thumbnails{% endtrans %}</label></td>
|
||||
<td>
|
||||
<select id="thumbtitle">
|
||||
<option value="1" <%= field.thumbtitle == "1" ? "selected" : "" %> >{% trans 'Tous' %}</option>
|
||||
<option value="0" <%= field.thumbtitle == "0" ? "selected" : "" %> >{% trans 'Aucun' %}</option>
|
||||
<option value="fr" <%= field.thumbtitle == "fr" ? "selected" : "" %> >{% trans 'Francais' %}</option>
|
||||
<option value="nl" <%= field.thumbtitle == "nl" ? "selected" : "" %> >{% trans 'Dutch' %}</option>
|
||||
<option value="de" <%= field.thumbtitle == "de" ? "selected" : "" %> >{% trans 'Allemand' %}</option>
|
||||
<option value="en" <%= field.thumbtitle == "en" ? "selected" : "" %> >{% trans 'Anglais' %}</option>
|
||||
<option value="ar" <%= field.thumbtitle == "ar" ? "selected" : "" %> >{% trans 'Arabe' %}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="list_row_template">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="handle">
|
||||
<i class="icon-move"></i>
|
||||
</td>
|
||||
<td rowspan="2" class="trigger-click">
|
||||
<div class="field-name"><%= name %></div>
|
||||
<div class="field-tag"><%= tag %></div>
|
||||
</td>
|
||||
<td rowspan="2" class="chip trigger-click">
|
||||
<i class="icon-chevron-right"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="position">
|
||||
<%= position %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="dc_fields_template">
|
||||
<select id="dces-element" class="input-block-level">
|
||||
<option <%= field['dces-element'] == null ? 'selected' : '' %> value=''></option>
|
||||
<% _.each(dces_elements, function(el) { %>
|
||||
<option <%= field['dces-element'] == el.label ? 'selected' : '' %> value="<%= el.label %>">DC:<%= el.label %></option>
|
||||
<% }); %>
|
||||
</select>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="field_error_template">
|
||||
<% if(messages.length > 0) { %>
|
||||
<div class="well well-small">
|
||||
<i class="icon-exclamation-sign"></i> {% trans %}Current configuration contains some errors{% endtrans %}
|
||||
</div>
|
||||
<% } %>
|
||||
</script>
|
55
www/scripts/tests/fixtures/home/login/form
vendored
55
www/scripts/tests/fixtures/home/login/form
vendored
@@ -1,55 +0,0 @@
|
||||
<form novalidate="" name="loginForm" method="POST" action="#">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="login" class="required">Login</label>
|
||||
<table class="input-table">
|
||||
<tbody><tr>
|
||||
<td class="icon">
|
||||
<i class="icon-envelope icon-white"></i>
|
||||
</td>
|
||||
<td class="input">
|
||||
<input type="text" id="login" name="login" required="required" class="input-block-level">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<div class="error-view"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="password" class="required">Password</label>
|
||||
<table class="input-table">
|
||||
<tbody><tr>
|
||||
<td class="icon">
|
||||
<i class="icon-lock icon-white"></i>
|
||||
</td>
|
||||
<td class="input">
|
||||
<input type="password" id="password" name="password" required="required" class="input-block-level">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<div class="error-view"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="forget-password-link" href="/login/forgot-password/">Forgot password?</a>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<button type="submit" class="btn btn-success btn-trigger">
|
||||
Connection
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="remember-me" class="checkbox">
|
||||
<input type="checkbox" id="remember-me" name="remember-me" checked="checked" value="1">
|
||||
Remember me
|
||||
</label>
|
||||
<div class="error-view"></div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="redirect" name="redirect"><input type="hidden" id="_token" name="_token" value="76b1bdee87734050bb1ab237c162f1211eda0622">
|
||||
</form>
|
23
www/scripts/tests/fixtures/home/login/templates
vendored
23
www/scripts/tests/fixtures/home/login/templates
vendored
@@ -1,23 +0,0 @@
|
||||
<script type="text/template" id="field_errors">
|
||||
<div class="hidden-phone popover bottom field-error">
|
||||
<div class="arrow"></div>
|
||||
<div class="popover-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:35px;"><i class="icon-warning-sign icon-white"></i></td>
|
||||
<td>
|
||||
<% _.each(errors, function(error) { %>
|
||||
<div><%= error.message %></div>
|
||||
<% }); %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class="visible-phone text-error help-block help-block-error">
|
||||
<% _.each(errors, function(error) { %>
|
||||
<td> <%= error.message %></td>
|
||||
<% }); %>
|
||||
</span>
|
||||
</script>
|
@@ -14,6 +14,7 @@
|
||||
require([
|
||||
'tests/baseTest',
|
||||
'specs/admin/fields',
|
||||
'specs/admin/taskmanager',
|
||||
'specs/login/home',
|
||||
'specs/models',
|
||||
'specs/validator'
|
||||
|
@@ -4,7 +4,6 @@ require.config({
|
||||
specs: "tests/specs",
|
||||
chai: "../assets/chai/chai",
|
||||
fixtures: "../assets/js-fixtures/fixtures",
|
||||
app: "apps/admin/fields/app",
|
||||
jquery: "../assets/jquery/jquery",
|
||||
jqueryui: "../assets/jquery.ui/jquery-ui",
|
||||
underscore: "../assets/underscore-amd/underscore",
|
||||
|
@@ -2,7 +2,7 @@ define([
|
||||
'chai',
|
||||
'fixtures',
|
||||
'jquery',
|
||||
'app',
|
||||
'apps/admin/fields/app',
|
||||
'models/field',
|
||||
'apps/admin/fields/collections/fields',
|
||||
'apps/admin/fields/collections/dcFields',
|
||||
@@ -20,13 +20,16 @@ define([
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
|
||||
// load fixtures in dom
|
||||
// Note: fixture are loaded into scripts/tests/fixtures directory using
|
||||
// bin/developer phraseanet:regenerate-js-fixtures
|
||||
fixtures.path = 'fixtures';
|
||||
$("body").append(fixtures.read('admin/fields/dom', 'admin/fields/templates'));
|
||||
$("body").append(fixtures.read('admin/fields/index.html', 'admin/fields/templates.html'));
|
||||
var sbasId = 1;
|
||||
|
||||
App.create();
|
||||
|
||||
AdminFieldApp.languages = {"de":"Deutsch","en":"English","fr":"Francais","nl":"Dutch"};
|
||||
|
||||
describe("Admin field", function () {
|
||||
describe("Initialization", function () {
|
||||
it("should create a global variable", function () {
|
||||
|
103
www/scripts/tests/specs/admin/taskmanager.js
Normal file
103
www/scripts/tests/specs/admin/taskmanager.js
Normal file
@@ -0,0 +1,103 @@
|
||||
define([
|
||||
'chai',
|
||||
'fixtures',
|
||||
'jquery',
|
||||
'apps/admin/tasks-manager/app',
|
||||
'models/task',
|
||||
'apps/admin/tasks-manager/collections/tasks',
|
||||
'apps/admin/tasks-manager/views/ping',
|
||||
'apps/admin/tasks-manager/views/task',
|
||||
'apps/admin/tasks-manager/views/tasks'
|
||||
], function (chai, fixtures, $, App, TaskModel, TaskCollection, PingView, TaskView, TasksView) {
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
|
||||
// Note: fixture are loaded into scripts/tests/fixtures directory using
|
||||
// bin/developer phraseanet:regenerate-js-fixtures
|
||||
fixtures.path = 'fixtures';
|
||||
$("body").append(fixtures.read('admin/task-manager/templates.html', 'admin/task-manager/index.html'));
|
||||
|
||||
App.create();
|
||||
|
||||
describe("Admin task manager", function () {
|
||||
describe("Initialization", function () {
|
||||
it("should create a global variable", function () {
|
||||
should.exist(TaskManagerApp);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Views", function () {
|
||||
describe("TaskView", function () {
|
||||
beforeEach(function () {
|
||||
this.view = new TaskView({
|
||||
model: new TaskModel({
|
||||
"name":"Task", "configuration":"start", "actual": "stopped", "id":1, "urls" : []
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it("render() should return the view object", function () {
|
||||
this.view.render().should.equal(this.view);
|
||||
this.view.renderId().should.equal(this.view);
|
||||
this.view.renderConfiguration().should.equal(this.view);
|
||||
this.view.renderActual().should.equal(this.view);
|
||||
this.view.renderPid().should.equal(this.view);
|
||||
this.view.renderName().should.equal(this.view);
|
||||
});
|
||||
|
||||
it("should render as a TR element", function () {
|
||||
this.view.render().el.nodeName.should.equal("TR");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Empty Tasks item views", function () {
|
||||
beforeEach(function () {
|
||||
this.collection = new TaskCollection([]);
|
||||
this.view = new TasksView({
|
||||
collection: this.collection,
|
||||
el: AdminFieldApp.$tasksListView
|
||||
});
|
||||
});
|
||||
|
||||
it("should include list items for all models in collection", function () {
|
||||
this.view.render();
|
||||
this.view.$el.find("tr").length.should.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tasks Item Views", function () {
|
||||
beforeEach(function () {
|
||||
this.collection = new TaskCollection([
|
||||
{"name" : "task", "actual":"stopped", "configuration": "start", "urls" : []},
|
||||
{"name" : "task2", "actual":"stopped", "configuration": "start", "urls" : []}
|
||||
]);
|
||||
|
||||
this.view = new TasksView({
|
||||
collection: this.collection,
|
||||
el: AdminFieldApp.$tasksListView
|
||||
});
|
||||
});
|
||||
|
||||
it("render() should return the view object", function () {
|
||||
this.view.render().should.equal(this.view);
|
||||
});
|
||||
|
||||
it("should include list items for all models in collection", function () {
|
||||
this.view.render();
|
||||
this.view.$el.find("tr").length.should.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ping View", function () {
|
||||
beforeEach(function () {
|
||||
this.view = new PingView();
|
||||
});
|
||||
|
||||
it("render() should return the view object", function () {
|
||||
this.view.render().should.equal(this.view);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -9,9 +9,10 @@ define([
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
|
||||
// Note: fixture are loaded into scripts/tests/fixtures directory using
|
||||
// bin/developer phraseanet:regenerate-js-fixtures
|
||||
fixtures.path = 'fixtures';
|
||||
$("body").append(fixtures.read('home/login/form', 'home/login/templates'));
|
||||
$("body").append(fixtures.read('home/login/index.html', 'home/login/templates.html'));
|
||||
|
||||
describe("Login Home", function () {
|
||||
describe("Form View", function () {
|
||||
|
Reference in New Issue
Block a user