import CustomRulesView from './rule/custom-rules-view';
import ManualRuleCreationView from './rule/manual-rule-creation-view';
import CustomRuleCreationView from './rule/custom-rule-creation-view';
+import DeleteRuleView from './rule/delete-rule-view';
import IssuesView from './rule/rule-issues-view';
import Template from './templates/coding-rules-rule-details.hbs';
-import confirmDialog from './confirm-dialog';
-import { translate, translateWithParameters } from '../../helpers/l10n';
export default Marionette.LayoutView.extend({
className: 'coding-rule-details',
},
deleteRule () {
- const that = this;
- const ruleType = this.model.has('templateKey') ? 'custom' : 'manual';
- confirmDialog({
- title: translate('delete'),
- html: translateWithParameters(`coding_rules.delete.${ruleType}.confirm`, this.model.get('name')),
- yesHandler () {
- const url = '/api/rules/delete';
- const options = { key: that.model.id };
- $.post(url, options).done(function () {
- that.options.app.controller.fetchList();
- });
- }
+ const deleteRuleView = new DeleteRuleView({
+ model: this.model
+ }).render();
+
+ deleteRuleView.on('delete', () => {
+ this.options.app.controller.fetchList();
});
},
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import $ from 'jquery';
import _ from 'underscore';
import Marionette from 'backbone.marionette';
+import DeleteRuleView from './delete-rule-view';
import Template from '../templates/rule/coding-rules-custom-rule.hbs';
-import confirmDialog from '../confirm-dialog';
-import { translate } from '../../../helpers/l10n';
export default Marionette.ItemView.extend({
tagName: 'tr',
},
deleteRule () {
- const that = this;
- confirmDialog({
- title: translate('delete'),
- html: translate('are_you_sure'),
- yesHandler () {
- const url = '/api/rules/delete';
- const options = { key: that.model.id };
- $.post(url, options).done(function () {
- that.model.collection.remove(that.model);
- that.destroy();
- });
- }
+ const deleteRuleView = new DeleteRuleView({
+ model: this.model
+ }).render();
+
+ deleteRuleView.on('delete', () => {
+ this.model.collection.remove(this.model);
+ this.destroy();
});
},
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import $ from 'jquery';
+
+import ModalFormView from '../../../components/common/modal-form';
+import Template from '../templates/rule/coding-rules-delete-rule.hbs';
+
+export default ModalFormView.extend({
+ template: Template,
+
+ onFormSubmit() {
+ ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+
+ const url = '/api/rules/delete';
+ const options = { key: this.model.id };
+ $.post(url, options).done(() => {
+ this.destroy();
+ this.trigger('delete');
+ });
+ }
+});
--- /dev/null
+<form>
+ <div class="modal-head">
+ <h2>{{t 'coding_rules.delete_rule'}}</h2>
+ </div>
+
+ <div class="modal-body">
+ {{tp 'coding_rules.delete.custom.confirm' name}}
+ </div>
+
+ <div class="modal-foot">
+ <button className="button-red">{{t 'delete'}}</button>
+ <a class="js-modal-close">{{t 'cancel'}}</a>
+ </div>
+</form>