[minor] confirm before installing app

This commit is contained in:
Rushabh Mehta 2015-12-02 14:46:23 +05:30
parent 0127589cbe
commit 4b3aeb3fb8
2 changed files with 27 additions and 19 deletions

View file

@ -4,19 +4,25 @@
{{ app.featured ? "data-featured=1" : "" }}>
<div class="media">
<div class="pull-right app-buttons">
<a class="btn btn-default btn-xs" href="{{ app.app_url }}" target="_blank">{%= __("Website") %}</a>
<a class="btn btn-default btn-xs"
href="{{ app.app_url }}" target="_blank">{{ __("Website") }}</a>
{% if (app.installed) { %}
<button class="btn btn-default btn-xs" disabled=disabled>{%= __("Installed") %}</button>
<button class="btn btn-default btn-xs" disabled=disabled>
{{ __("Installed") }}</button>
{% } else { %}
<button class="btn btn-primary btn-xs install" data-app="{%= app.app_name %}">{%= __("Install") %}</button>
<button class="btn btn-primary btn-xs install"
data-app="{{ app.app_name }}"
data-title="{{ app.app_title }}"
>{{ __("Install") }}</button>
{% } %}
</div>
<div class="pull-left app-icon-wrapper">{%= app.app_icon %}</div>
<div class="pull-left app-icon-wrapper">{{ app.app_icon }}</div>
<div class="media-body">
<h5 class="media-heading">{%= app.app_title %}</h5>
<h5 class="media-heading">{{ app.app_title }}</h5>
<div class="text-muted">
{%= app.app_description %}<br>
{%= __("Publisher") %}: {%= app.app_publisher %} | {%= __("Version") %}: {%= app.app_version %}
{{ app.app_description }}<br>
{{ __("Publisher") }}: {{ app.app_publisher }}
| {{ __("Version") }}: {{ app.app_version }}
</div>
</div>
</div>

View file

@ -147,7 +147,7 @@ frappe.applications.Installer = Class.extend({
+ __('No matching apps found') + '</p>').appendTo(me.wrapper).toggle(false);
this.wrapper.find(".install").on("click", function() {
me.install_app($(this).attr("data-app"), this);
me.install_app($(this).attr("data-app"), $(this).attr("data-title"), this);
});
},
@ -156,18 +156,20 @@ frappe.applications.Installer = Class.extend({
this.no_result.toggle(this.wrapper.find(".app-listing:visible").length ? false : true);
},
install_app: function(app_name, btn) {
frappe.call({
method: "frappe.desk.page.applications.applications.install_app",
args: { name: app_name },
freeze: true,
btn: btn,
callback: function(r) {
if(!r.exc) {
frappe.update_msgprint(__("Refreshing..."));
setTimeout(function() { window.location.reload() }, 2000)
install_app: function(app_name, app_title, btn) {
frappe.confirm(__("Install {0}?", [app_title]), function() {
frappe.call({
method: "frappe.desk.page.applications.applications.install_app",
args: { name: app_name },
freeze: true,
btn: btn,
callback: function(r) {
if(!r.exc) {
frappe.update_msgprint(__("Refreshing..."));
setTimeout(function() { window.location.reload() }, 2000)
}
}
}
});
});
},