Move out Merlin and Mistral code into separate modules

Unit-testing would be easier this way.

Also clean up some remaining bits of previous version of
Mistral Workbook builder.

Implements blueprint: merlin-unittests
Change-Id: Ie82a5fd19fcd5e98d7c9d2321a9a8c93495af07f
This commit is contained in:
Timur Sufiev 2015-03-31 07:43:37 -07:00
parent f9bb5fa11a
commit 1454a2792d
16 changed files with 30 additions and 115 deletions

View File

@ -10,5 +10,7 @@ ADD_INSTALLED_APPS = ['merlin', 'mistral']
# Python panel class of the PANEL to be added.
ADD_PANEL = 'mistral.panel.MistralPanel'
ADD_ANGULAR_MODULES = ['angular.filter']
ADD_JS_FILES = ['merlin/lib/angular-filter.js']
ADD_ANGULAR_MODULES = ['angular.filter', 'merlin', 'mistral']
ADD_JS_FILES = ['merlin/js/lib/angular-filter.js',
'merlin/js/merlin.init.js',
'mistral/js/mistral.init.js']

View File

@ -1,34 +0,0 @@
/* Copyright (c) 2014 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
*/
.expandable:before {
content: '+';
}
.expandable.expanded:before {
content: '-';
}
.container-action {
padding-left: 5px;
}
.inner-node {
padding-left: 5px;
border-left: 1px solid green;
}
div#create-workbook {
padding-left: 15px;
padding-right: 15px;
}

View File

@ -2,8 +2,9 @@
* Created by tsufiev on 2/24/15.
*/
(function() {
angular.module('hz')
'use strict';
var mistralApp = angular.module('mistral', ['merlin'])
.run(function($http, $templateCache) {
var fields = ['varlist', 'yaqllist'];
fields.forEach(function(field) {

View File

@ -2,8 +2,9 @@
* Created by tsufiev on 2/24/15.
*/
(function() {
angular.module('hz')
'use strict';
angular.module('mistral')
.controller('workbookCtrl',
['$scope', 'mistral.workbook.models', function($scope, models) {
var workbook = models.Workbook.create({name: 'My Workbook'});

View File

@ -1,9 +1,10 @@
/**
* Created by tsufiev on 2/24/15.
*/
(function(){
angular.module('hz')
(function() {
'use strict';
angular.module('mistral')
.factory('mistral.workbook.models',
['merlin.field.models', 'merlin.panel.models', function(fields, panel) {
var models = {};

View File

@ -1,46 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}create_workbook{% endblock %}
{% block form_action %}
{% if form.initial.workbook_id %}
{% url 'horizon:project:mistral:edit' form.initial.workbook_id %}
{% else %}
{% url 'horizon:project:mistral:create' %}
{% endif %}
{% endblock %}
{% block modal-header %}
{% if form.initial.workbook_id %}
{% trans "Edit Workbook" %}
{% else %}
{% trans "Create Workbook" %}
{% endif %}
{% endblock %}
{% block modal_id %}create_workbook_modal{% endblock %}
{% block modal-body %}
<div class="left">
<div id="toolbar">
<button id="create-workbook">Reset Workbook</button>
<button id="save-workbook">Update YAML presentation</button>
<div id="controls"></div>
</div>
</div>
<div class="right">
<pre></pre>
<input name="workbook" id="json-output" type="hidden" value="{{ form.initial.workbook }}"/>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit"
value="{% if form.initial.workbook_id %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}" />
<a href="{% url 'horizon:project:mistral:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
{% block modal-js %}
<script src="{{ STATIC_URL }}mistral/js/schema.js"></script>
<script src="{{ STATIC_URL }}mistral/js/workbook.js"></script>
{% endblock %}

View File

@ -13,9 +13,9 @@
{% include "horizon/_scripts.html" %}
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/lib/barricade.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/lib/js-yaml.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.init.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.directives.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.field.models.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.init.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.panel.models.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}merlin/js/merlin.utils.js"></script>
@ -28,8 +28,7 @@
{% block css %}
{% include "_stylesheets.html" %}
{% compress css %}
<link rel="stylesheet" href="{{ STATIC_URL }}mistral/css/mistral.css">
<link href='{{ STATIC_URL }}mistral/css/mistral.scss' type='text/scss' media='screen' rel='stylesheet' />
<link href='{{ STATIC_URL }}merlin/scss/merlin.scss' type='text/scss' media='screen' rel='stylesheet' />
{% endcompress %}
{% block merlin-css %}{% endblock %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends 'merlin/base.html' %}
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Workbooks" %}{% endblock %}

View File

@ -2,6 +2,8 @@
* Created by tsufiev on 2/24/15.
*/
(function() {
'use strict';
function disableClickDefaultBehaviour(element) {
element.find('a[data-toggle="collapse"]')
.on('click', function(e) {
@ -10,8 +12,7 @@
});
}
angular.module('hz')
angular.module('merlin')
.directive('editable', function() {
return {
restrict: 'E',
@ -30,7 +31,6 @@
}
};
})
.directive('panel', function($parse) {
return {
restrict: 'E',
@ -46,7 +46,6 @@
}
}
})
.directive('collapsibleGroup', function() {
return {
restrict: 'E',
@ -68,7 +67,6 @@
}
}
})
.directive('typedField', function($http, $templateCache, $compile) {
return {
restrict: 'E',

View File

@ -1,7 +1,8 @@
(function() {
angular.module('hz')
'use strict';
angular.module('merlin')
.factory('merlin.field.models',
['merlin.utils', 'merlin.panel.models', function(utils, panels) {
@ -195,4 +196,5 @@
wildcard: wildcardMixin // use for most general type-checks
};
}])
})();

View File

@ -2,8 +2,9 @@
* Created by tsufiev on 2/24/15.
*/
(function() {
angular.module('hz')
'use strict';
var merlinApp = angular.module('merlin', [])
.run(function($http, $templateCache) {
var fields = ['dictionary', 'frozendict', 'list', 'string',
'text', 'group', 'number', 'choices'

View File

@ -1,9 +1,10 @@
/**
* Created by tsufiev on 2/24/15.
*/
(function(){
angular.module('hz')
(function() {
'use strict';
angular.module('merlin')
.factory('merlin.panel.models', ['merlin.utils', function(utils) {
var rowProto = {
create: function(items) {
@ -148,4 +149,5 @@
rowmixin: rowMixin
}
}])
})();

View File

@ -1,9 +1,10 @@
/**
* Created by tsufiev on 2/24/15.
*/
(function(){
angular.module('hz')
(function() {
'use strict';
angular.module('merlin')
.factory('merlin.utils', function() {
Array.prototype.condense = function() {
return this.filter(function(el) {
@ -80,4 +81,5 @@
enhanceItemWithID: enhanceItemWithID
}
})
})();

View File

@ -1 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}

View File

@ -1,13 +0,0 @@
{% extends "base.html" %}
{% block js %}
{% include "horizon/_scripts.html" %}
<script src="{{ STATIC_URL }}merlin/lib/barricade.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ STATIC_URL }}merlin/lib/js-yaml.js" type="text/javascript" charset="utf-8"></script>
{% block merlin-js-scripts %}{% endblock %}
{% endblock %}
{% block css %}
{% include "_stylesheets.html" %}
{% block merlin-css %}{% endblock %}
{% endblock %}