зеркало из https://github.com/mozilla/FlightDeck.git
adding dependency working (no status update yet)
This commit is contained in:
Родитель
b1fd6e41cb
Коммит
76cd884539
|
@ -94,9 +94,9 @@ var Capability = new Class({
|
|||
this.version.addEvent('change', this.boundAfterVersionChanged);
|
||||
this.description_el.addEvent('change', this.boundAfterDataChanged);
|
||||
// one may try even not edited data
|
||||
this.try_in_browser_el = $(this.options.try_in_browser_el)
|
||||
if (this.try_in_browser_el) {
|
||||
this.try_in_browser_el.addEvent('click', function(e) {
|
||||
var try_in_browser_el = $(this.options.try_in_browser_el)
|
||||
if (try_in_browser_el) {
|
||||
try_in_browser_el.addEvent('click', function(e) {
|
||||
e.stop();
|
||||
this.try_in_browser();
|
||||
}.bind(this));
|
||||
|
@ -242,6 +242,9 @@ var CapVersion = new Class({
|
|||
},
|
||||
update_el: 'update',
|
||||
set_as_base_el: 'set_as_base',
|
||||
add_dependency_el: 'add_dependency_action',
|
||||
add_dependency_input: 'add_dependency',
|
||||
add_dependency_url: '',
|
||||
edit_url: '',
|
||||
update_url: '',
|
||||
set_as_base_url: '',
|
||||
|
@ -269,6 +272,12 @@ var CapVersion = new Class({
|
|||
e.stop();
|
||||
this.setAsBase();
|
||||
}.bind(this));
|
||||
},
|
||||
/*
|
||||
* Method: addDependency
|
||||
*/
|
||||
addDependency: function() {
|
||||
|
||||
},
|
||||
/*
|
||||
* Method: instantiateEditors
|
||||
|
@ -317,6 +326,36 @@ var CapVersion = new Class({
|
|||
this.boundAfterDataChanged = this.afterDataChanged.bind(this);
|
||||
this.description_el.addEvent('change', this.boundAfterDataChanged);
|
||||
this.content_el.addEvent('change', this.boundAfterDataChanged);
|
||||
// adding dependencies
|
||||
var add_dependency_action = $(this.options.add_dependency_el);
|
||||
if (add_dependency_action) {
|
||||
add_dependency_action.addEvent('click', function(e) {
|
||||
e.stop();
|
||||
this.addDependencyFromInput();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
/*
|
||||
* Method: addDependencyFromInput
|
||||
*/
|
||||
addDependencyFromInput: function() {
|
||||
dependency_slug = $(this.options.add_dependency_input).get('value');
|
||||
// TODO: some validation
|
||||
// TODO: add not base version
|
||||
new Request.JSON({
|
||||
url: this.options.add_dependency_url,
|
||||
method: 'post',
|
||||
data: {'dependency_slug': dependency_slug},
|
||||
onSuccess: function(response) {
|
||||
fd.message.alert('Success',response.message);
|
||||
this.createDependency(response.dependency);
|
||||
}.bind(this)
|
||||
}).send();
|
||||
},
|
||||
createDependency: function(data) {
|
||||
// TODO: create DOM
|
||||
// TODO: create Item
|
||||
console.dir(data);
|
||||
},
|
||||
afterDataChanged: function() {
|
||||
// TODO: discover if change was actually an undo and there is
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="UI_Field_Cont UI_New_Dependency">
|
||||
<label for="add_dependency">Add dependency</label>
|
||||
<input type="text" id="add_dependency" name="add_dependency" value="" />
|
||||
<button id="add_dependecy_action">Add</button>
|
||||
<button id="add_dependency_action">Add</button>
|
||||
</div>
|
||||
|
||||
{% with version.capabilities.all as capabilities %}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
edit_url: '{{ version.get_absolute_url }}',
|
||||
update_url: '{{ version.get_update_url }}',
|
||||
set_as_base_url: '{{ version.get_set_as_base_url }}',
|
||||
{% if version %}
|
||||
add_dependency_url: '{% url jp_capability_add_dependency capability.slug version.name version.counter %}',
|
||||
{% endif %}
|
||||
switch_description_id: '{{ version|tab_link_id:"version_description" }}',
|
||||
switch_content_id: '{{ version|tab_link_id:"content" }}'
|
||||
}
|
||||
|
@ -55,16 +58,18 @@
|
|||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="capabilities" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler capabilities opened"><a title="Capabilities" href="#">
|
||||
Capabilities
|
||||
<span class="UI_OC"></span>
|
||||
<span class="UI_Sidebar_Toggler_Icon"></span>
|
||||
</a></h3>
|
||||
<div class="UI_Sidebar_ItemCont">
|
||||
{% include "_dependency_list.html" %}
|
||||
</div>
|
||||
</section>
|
||||
{% if version %}
|
||||
<section id="capabilities" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler capabilities opened"><a title="Capabilities" href="#">
|
||||
Capabilities
|
||||
<span class="UI_OC"></span>
|
||||
<span class="UI_Sidebar_Toggler_Icon"></span>
|
||||
</a></h3>
|
||||
<div class="UI_Sidebar_ItemCont">
|
||||
{% include "_dependency_list.html" %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section id="info" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler info opened"><a title="Info" href="#">
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
is_base: {{ version.is_base|yesno:"true,false" }},
|
||||
edit_url: '{{ version.get_absolute_url }}',
|
||||
update_url: '{{ version.get_update_url }}',
|
||||
{% if version %}
|
||||
add_dependency_url: '{% url jp_jetpack_add_dependency jetpack.slug version.name version.counter %}',
|
||||
{% endif %}
|
||||
set_as_base_url: '{{ version.get_set_as_base_url }}',
|
||||
switch_content_id: '{{ version|tab_link_id:"content" }}',
|
||||
switch_description_id: '{{ version|tab_link_id:"version_description" }}',
|
||||
|
@ -61,16 +64,18 @@
|
|||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="capabilities" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler capabilities opened"><a title="Capabilities" href="#">
|
||||
Capabilities
|
||||
<span class="UI_OC"></span>
|
||||
<span class="UI_Sidebar_Toggler_Icon"></span>
|
||||
</a></h3>
|
||||
<div class="UI_Sidebar_ItemCont">
|
||||
{% include "_dependency_list.html" %}
|
||||
</div>
|
||||
</section>
|
||||
{% if version %}
|
||||
<section id="capabilities" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler capabilities opened"><a title="Capabilities" href="#">
|
||||
Capabilities
|
||||
<span class="UI_OC"></span>
|
||||
<span class="UI_Sidebar_Toggler_Icon"></span>
|
||||
</a></h3>
|
||||
<div class="UI_Sidebar_ItemCont">
|
||||
{% include "_dependency_list.html" %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section id="info" class="UI_Side_Item">
|
||||
<h3 class="UI_Sidebar_Toggler info opened"><a title="Info" href="#">
|
||||
|
@ -96,14 +101,12 @@
|
|||
|
||||
<p class="UI_Sidebar_Creator">Origin by: <a title="{{ jetpack.creator }}" href="{% url person_public_profile jetpack.creator.username %}">{{ jetpack.creator }}</a></p>
|
||||
|
||||
{% ifequal jetpack.creator.username version.author.username %}
|
||||
{% if version %}{% ifequal jetpack.creator.username version.author.username %}
|
||||
{% else %}
|
||||
{% if version %}
|
||||
<p class="UI_Sidebar_Author">{{ version.fullname }} by:
|
||||
<a title="{{ version.author }}" href="{% url person_public_profile version.author.username %}">{{ version.author }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% endifequal %}{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
@ -138,18 +141,3 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% comment %}
|
||||
<h1>{% if jetpack_page %}{{ jetpack }}{% else %}{{ version }}{% endif %}
|
||||
by <a href="{% url person_public_profile jetpack.creator.username %}">{{ jetpack.creator.username }}</a>
|
||||
</h1>
|
||||
|
||||
{% if version %}
|
||||
<p>
|
||||
Version by: <a title="{{ version.author.username }}" href="{% url person_public_profile version.author.username %}">{{ version.author.username }}</a>,
|
||||
{% if jetpack_page %}switch to: <a title="{{ version.fullname }}" href="{{ version.get_absolute_url }}">version {{ version.fullname }}</a>
|
||||
{% else %}switch to: <a title="" href="{{ jetpack.get_absolute_url }}">jetpack base</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"message": "module \"{{ cap.fullname }}\" added as dependency to \"{{ item.fullname }}\"",
|
||||
"dependency": {
|
||||
"slug": "{{ cap.slug }}",
|
||||
"name": "{{ cap.name }}",
|
||||
"creator": "{{ cap.creator }}",
|
||||
"version_create_url": "{{ cap.get_version_create_url }}",
|
||||
"version": {
|
||||
"author": "{{ version.author }}",
|
||||
"name": "{{ version.name }}",
|
||||
"description": "{{ version.description|escapejs }}",
|
||||
"content": "{{ version.content|escapejs }}",
|
||||
"is_base": {{ capversion.is_base|yesno:"true,false" }},
|
||||
"edit_url": "{{ version.get_absolute_url }}",
|
||||
"update_url": "{{ version.get_update_url }}",
|
||||
"switch_content_id": "dependency_{{ cap.slug }}",
|
||||
"content_el": {
|
||||
"element": "dependency_content_{{ cap.slug }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,8 @@ urlpatterns = patterns('jetpack.views',
|
|||
'jetpack_version_update', name='jp_jetpack_version_update'),
|
||||
url(r'^jp_(?P<slug>.*)/update/$',
|
||||
'jetpack_update', name='jp_jetpack_update'),
|
||||
url(r'^jp_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/add_dependency/$',
|
||||
'add_dependency', {'type': 'jetpack'}, name='jp_jetpack_add_dependency'),
|
||||
url(r'^jp_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/save_as_base/$',
|
||||
'jetpack_version_save_as_base', name='jp_jetpack_version_save_as_base'),
|
||||
url(r'^jp/create',
|
||||
|
|
|
@ -298,21 +298,29 @@ def capabilities_autocomplete(r):
|
|||
"""
|
||||
|
||||
@login_required
|
||||
def add_dependency(r, slug, version, counter):
|
||||
def add_dependency(r, slug, type, version=None, counter=None):
|
||||
"""
|
||||
Add dependency to the item represented by slug
|
||||
"""
|
||||
try:
|
||||
if type == 'jetpack':
|
||||
item = JetVersion.objects.get(jetpack__slug=slug, name=version, counter=counter)
|
||||
except:
|
||||
elif type == 'capability':
|
||||
item = get_object_or_404(CapVersion, capability__slug=slug, name=version, counter=counter)
|
||||
|
||||
dependency_slug = r.POST.get("dependency_slug")
|
||||
dependency_version = r.POST.get("dependency_version")
|
||||
dependency_counter = r.POST.get("dependency_counter")
|
||||
dependency = CapVersion.objects.get(slug=dependency_slug)
|
||||
dependency_version = r.POST.get("dependency_version", None)
|
||||
dependency_counter = r.POST.get("dependency_counter", None)
|
||||
if version:
|
||||
dependency = CapVersion.objects.get(capability__slug=dependency_slug, name=version, counter=counter)
|
||||
else:
|
||||
cap = Cap.objects.get(slug=dependency_slug)
|
||||
dependency = cap.base_version
|
||||
|
||||
item.capabilities.add(dependency)
|
||||
item.save()
|
||||
|
||||
return render_to_response('json/dependency_added.json',
|
||||
{'item': item, 'version': dependency, 'cap': dependency.capability},
|
||||
context_instance=RequestContext(r),
|
||||
mimetype='application/json')
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче