зеркало из https://github.com/mozilla/FlightDeck.git
Merge branch 'master' of git@github.com:zalun/FlightDeck
This commit is contained in:
Коммит
b52f55702a
|
@ -89,9 +89,28 @@ var CapVersionDependency = new Class({
|
|||
if (this.switch_content_el) {
|
||||
this.switch_content_el.addEvent('click', this.switchToContent.bind(this));
|
||||
this.switch_content_el.getChildren('.File_close').addEvent('click', function(e) {
|
||||
});
|
||||
e.stopPropagation();
|
||||
this.unassign();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
unassign: function() {
|
||||
new Request.JSON({
|
||||
url: this.options.remove_url,
|
||||
data: {},
|
||||
onSuccess: function(response) {
|
||||
fd.message.alert('Success',response.message);
|
||||
if (!this.content_el.hidden) {
|
||||
// this is actually wrong
|
||||
fd.getItem().version.switch_content_el.fireEvent('click', e);
|
||||
}
|
||||
this.content_el.destroy();
|
||||
this.switch_content_el.destroy();
|
||||
$H(fd.getItem().version.capabilities).erase(this.options.slug);
|
||||
this.fireEvent('remove');
|
||||
}.bind(this)
|
||||
}).send();
|
||||
},
|
||||
updateFromDOM: function() {
|
||||
this.data.version_content = this.content_el.getContent();
|
||||
},
|
||||
|
|
|
@ -40,13 +40,21 @@ var Editor = new Class({
|
|||
return this;
|
||||
},
|
||||
destroy: function() {
|
||||
this.hide();
|
||||
this.editor.clearHistory();
|
||||
this.editor.wrapping.destroy();
|
||||
this.element.destroy();
|
||||
},
|
||||
hide: function() {
|
||||
this.hidden = true;
|
||||
this.element.hide();
|
||||
this.fireEvent('hide');
|
||||
return this;
|
||||
},
|
||||
show: function() {
|
||||
this.hidden = false;
|
||||
this.element.show();
|
||||
this.fireEvent('show');
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -37,6 +37,15 @@ FlightDeck = Class.refactor(FlightDeck,{
|
|||
});
|
||||
});
|
||||
|
||||
},
|
||||
/*
|
||||
* Method: getItem
|
||||
*/
|
||||
getItem: function() {
|
||||
// item is currently a global
|
||||
// TODO: change to flightdeck parameter
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
creator: '{{ cap.creator }}',
|
||||
version_create_url: '{{ cap.get_version_create_url }}',
|
||||
version: {
|
||||
xxx: 'xxx',
|
||||
{% ifequal type "jetpack" %}
|
||||
remove_url: '{% url jp_jetpack_remove_dependency item.slug version.name version.counter cap.slug capversion.name capversion.counter %}',
|
||||
{% else %}
|
||||
remove_url: '{% url jp_capability_remove_dependency item.slug version.name version.counter cap.slug capversion.name capversion.counter %}',
|
||||
{% endifequal %}
|
||||
author: '{{ capversion.author }}',
|
||||
name: '{{ capversion.name }}',
|
||||
counter: {{ capversion.counter }},
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"creator": "{{ cap.creator }}",
|
||||
"version_create_url": "{{ cap.get_version_create_url }}",
|
||||
"version": {
|
||||
"remove_url": "{{ dependency_remove_url }}",
|
||||
"author": "{{ version.author }}",
|
||||
"name": "{{ version.name }}",
|
||||
"counter": {{ version.counter }},
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"message": "Dependency removed"}
|
|
@ -28,6 +28,11 @@ urlpatterns = patterns('jetpack.views',
|
|||
url(r'^mod_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/add_dependency/$',
|
||||
'add_dependency', {'type': 'capability'}, name='jp_capability_add_dependency'),
|
||||
|
||||
url(r'^jp_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/remove_dependency/(?P<d_slug>.*)/(?P<d_version>.*)/(?P<d_counter>\d+)/$',
|
||||
'remove_dependency', {'type': 'jetpack'}, name='jp_jetpack_remove_dependency'),
|
||||
url(r'^cap_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/remove_dependency/(?P<d_slug>.*)/(?P<d_version>.*)/(?P<d_counter>\d+)/$',
|
||||
'remove_dependency', {'type': 'capability'}, name='jp_capability_remove_dependency'),
|
||||
|
||||
url(r'^jp_(?P<slug>.*)/v_(?P<version>.*)\.(?P<counter>\d+)/save_as_base/$',
|
||||
'item_version_save_as_base', {'type': 'jetpack'},
|
||||
name='jp_jetpack_version_save_as_base'),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.http import Http404, HttpResponseRedirect, HttpResponse, HttpResponseNotAllowed
|
||||
from django.template import RequestContext#,Template
|
||||
|
@ -232,12 +233,15 @@ def add_dependency(r, slug, type, version=None, counter=None):
|
|||
"""
|
||||
Add dependency to the item represented by slug
|
||||
"""
|
||||
# TODO: add more protection (do not allow two versions of the same Cap)
|
||||
if type == 'jetpack':
|
||||
item = get_object_or_404(JetVersion,
|
||||
item_version = get_object_or_404(JetVersion,
|
||||
jetpack__slug=slug, name=version, counter=counter)
|
||||
item = item_version.jetpack
|
||||
elif type == 'capability':
|
||||
item = get_object_or_404(CapVersion,
|
||||
item_version = get_object_or_404(CapVersion,
|
||||
capability__slug=slug, name=version, counter=counter)
|
||||
item = item_version.capability
|
||||
|
||||
dependency_slug = r.POST.get("dependency_slug")
|
||||
dependency_version = r.POST.get("dependency_version", None)
|
||||
|
@ -247,18 +251,44 @@ def add_dependency(r, slug, type, version=None, counter=None):
|
|||
capability__slug=dependency_slug,
|
||||
name=dependency_version,
|
||||
counter=dependency_counter)
|
||||
cap = dependency.capability
|
||||
else:
|
||||
cap = Cap.objects.get(slug=dependency_slug)
|
||||
dependency = cap.base_version
|
||||
|
||||
item.capabilities.add(dependency)
|
||||
item.save()
|
||||
item_version.capabilities.add(dependency)
|
||||
item_version.save()
|
||||
|
||||
dependency_remove_url = reverse("jp_%s_remove_dependency" % type, args=[
|
||||
item.slug, item_version.name, item_version.counter,
|
||||
cap.slug, dependency.name, dependency.counter])
|
||||
|
||||
return render_to_response('json/dependency_added.json', {
|
||||
'item': item,
|
||||
'item': item_version,
|
||||
'version': dependency,
|
||||
'cap': dependency.capability
|
||||
'cap': dependency.capability,
|
||||
'dependency_remove_url': dependency_remove_url
|
||||
},
|
||||
context_instance=RequestContext(r),
|
||||
mimetype='application/json')
|
||||
|
||||
@login_required
|
||||
def remove_dependency(r, slug, version, counter, type, d_slug, d_version, d_counter):
|
||||
"""
|
||||
Remove dependency from item
|
||||
"""
|
||||
if type == 'jetpack':
|
||||
item_version = get_object_or_404(JetVersion,
|
||||
jetpack__slug=slug, name=version, counter=counter)
|
||||
elif type == 'capability':
|
||||
item_version = get_object_or_404(CapVersion,
|
||||
capability__slug=slug, name=version, counter=counter)
|
||||
|
||||
dependency = get_object_or_404(CapVersion,
|
||||
capability__slug=d_slug, name=d_version, counter=d_counter)
|
||||
|
||||
item_version.capabilities.remove(dependency)
|
||||
item_version.save()
|
||||
return render_to_response('json/dependency_removed.json', locals(),
|
||||
context_instance=RequestContext(r),
|
||||
mimetype='application/json')
|
||||
|
|
|
@ -14,9 +14,11 @@ Element.implement({
|
|||
? true
|
||||
: (w!==0 && h!==0 && !force) ? false : this.getStyle('display') === 'none';
|
||||
},
|
||||
|
||||
isVisible: function(){
|
||||
return !this.isHidden();
|
||||
},
|
||||
getSiblings: function(match,nocache) {
|
||||
return this.getParent().getChildren(match,nocache).erase(this);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -35,12 +37,6 @@ if (!console) {
|
|||
};
|
||||
}
|
||||
|
||||
Element.implement({
|
||||
getSiblings: function(match,nocache) {
|
||||
return this.getParent().getChildren(match,nocache).erase(this);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Class: FlightDeck
|
||||
* Initializes all needed functionality
|
||||
|
@ -62,5 +58,4 @@ var FlightDeck = new Class({
|
|||
hideEditors: function() {
|
||||
this.editors.each(function(ed){ ed.hide(); });
|
||||
},
|
||||
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче