mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-21 19:47:48 +00:00
First attempt at create rule form.
This commit is contained in:
@@ -52,13 +52,33 @@ class RuleController extends Controller
|
||||
if (Session::get('rules.rule-group.create.fromStore') !== true) {
|
||||
Session::put('rules.rule-group.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('accounts.create.fromStore');
|
||||
Session::forget('rules.rule-group.create.fromStore');
|
||||
Session::flash('gaEventCategory', 'rules');
|
||||
Session::flash('gaEventAction', 'create-rule-group');
|
||||
|
||||
return view('rules.rule-group.create', compact('subTitleIcon', 'what', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @return View
|
||||
*/
|
||||
public function createRule(RuleGroup $ruleGroup)
|
||||
{
|
||||
$subTitleIcon = 'fa-clone';
|
||||
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (Session::get('rules.rule.create.fromStore') !== true) {
|
||||
Session::put('rules.rule.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('rules.rule.create.fromStore');
|
||||
Session::flash('gaEventCategory', 'rules');
|
||||
Session::flash('gaEventAction', 'create-rule-group');
|
||||
|
||||
return view('rules.rule.create', compact('subTitleIcon','ruleGroup', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroupFormRequest $request
|
||||
* @param RuleRepositoryInterface $repository
|
||||
|
@@ -236,7 +236,8 @@ Route::group(
|
||||
Route::get('/rules', ['uses' => 'RuleController@index', 'as' => 'rules.index']);
|
||||
|
||||
// rules:
|
||||
Route::get('/rules/rules/create', ['uses' => 'RuleController@createRule', 'as' => 'rules.rule.create']);
|
||||
Route::get('/rules/create/{ruleGroup}', ['uses' => 'RuleController@createRule', 'as' => 'rules.rule.create']);
|
||||
|
||||
Route::get('/rules/rules/up/{rule}', ['uses' => 'RuleController@upRule', 'as' => 'rules.rule.up']);
|
||||
Route::get('/rules/rules/down/{rule}', ['uses' => 'RuleController@downRule', 'as' => 'rules.rule.down']);
|
||||
Route::get('/rules/rules/edit/{rule}', ['uses' => 'RuleController@editRule', 'as' => 'rules.rule.edit']);
|
||||
@@ -245,6 +246,10 @@ Route::group(
|
||||
Route::post('/rules/rules/trigger/reorder/{rule}', ['uses' => 'RuleController@reorderRuleTriggers']);
|
||||
Route::post('/rules/rules/action/reorder/{rule}', ['uses' => 'RuleController@reorderRuleActions']);
|
||||
|
||||
Route::post('/rules/store/{ruleGroup}', ['uses' => 'RuleController@storeRule', 'as' => 'rules.rule.store']);
|
||||
Route::post('/rules/update/{rule}', ['uses' => 'RuleController@updateRule', 'as' => 'rules.rule.update']);
|
||||
Route::post('/rules/destroy/{rule}', ['uses' => 'RuleController@destroyRule', 'as' => 'rules.rule.destroy']);
|
||||
|
||||
|
||||
// rule groups:
|
||||
Route::get('/rules/groups/create', ['uses' => 'RuleController@createRuleGroup', 'as' => 'rules.rule-group.create']);
|
||||
|
@@ -60,6 +60,8 @@ return [
|
||||
'move_rule_group_up' => 'Move rule group up',
|
||||
'move_rule_group_down' => 'Move rule group down',
|
||||
'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:',
|
||||
'make_new_rule' => 'Make new rule in rule group ":title"',
|
||||
'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.',
|
||||
|
||||
// actions and triggers
|
||||
'rule_trigger_user_action' => 'User action is ":trigger_value"',
|
||||
|
@@ -67,6 +67,7 @@ return [
|
||||
'filename' => 'File name',
|
||||
'mime' => 'Mime type',
|
||||
'size' => 'Size',
|
||||
'stop_processing' => 'Stop processing',
|
||||
|
||||
|
||||
'delete_account' => 'Delete account ":name"',
|
||||
|
@@ -105,16 +105,26 @@
|
||||
|
||||
</td>
|
||||
<td>{{ rule.title }}
|
||||
{% if rule.stop_processing %}
|
||||
<i class="fa fa-stop-circle-o"></i>
|
||||
{% endif %}
|
||||
|
||||
{% if rule.description != "" %}
|
||||
<small><br/>{{ rule.description }}</small>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% if rule.ruleTriggers.count > 0 %}
|
||||
<ul class="small rule-triggers" data-id="{{ rule.id }}">
|
||||
{% for trigger in rule.ruleTriggers %}
|
||||
{% if trigger.trigger_type != "user_action" %}
|
||||
<li data-id="{{ trigger.id }}">{{ trans(('firefly.rule_trigger_' ~ trigger.trigger_type), {trigger_value: trigger.trigger_value}) }}</li>
|
||||
<li data-id="{{ trigger.id }}">{{ trans(('firefly.rule_trigger_' ~ trigger.trigger_type), {trigger_value: trigger.trigger_value}) }}
|
||||
|
||||
{% if trigger.stop_processing %}
|
||||
<i class="fa fa-stop-circle-o"></i>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -124,7 +134,11 @@
|
||||
{% if rule.ruleActions.count > 0 %}
|
||||
<ul class="small rule-actions" data-id="{{ rule.id }}">
|
||||
{% for action in rule.ruleActions %}
|
||||
<li data-id="{{ action.id }}">{{ trans(('firefly.rule_action_' ~ action.action_type), {action_value: action.action_value}) }}</li>
|
||||
<li data-id="{{ action.id }}">{{ trans(('firefly.rule_action_' ~ action.action_type), {action_value: action.action_value}) }}
|
||||
{% if action.stop_processing %}
|
||||
<i class="fa fa-stop-circle-o"></i>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
@@ -140,7 +154,7 @@
|
||||
{% endif %}
|
||||
<p>
|
||||
<br/>
|
||||
<a href="{{ route('rules.rule.create') }}" class="btn btn-success">{{ 'new_rule'|_ }}</a>
|
||||
<a href="{{ route('rules.rule.create', ruleGroup.id) }}" class="btn btn-success">{{ 'new_rule'|_ }}</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
85
resources/views/rules/rule/create.twig
Normal file
85
resources/views/rules/rule/create.twig
Normal file
@@ -0,0 +1,85 @@
|
||||
{% extends "./layout/default.twig" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('rules.rule.store', ruleGroup.id)}) }}
|
||||
<input type="hidden" name="rule_group_id" value="{{ ruleGroup.id }}"/>
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.text('title') }}
|
||||
{{ ExpandedForm.checkbox('stop_processing',1,null, {helpText: trans('firefly.rule_help_stop_processing')}) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
|
||||
<!-- optional fields -->
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.textarea('description') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- RULE TRIGGERS -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'rule_triggers'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
Here
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- RULE ACTIONS -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'rule_actions'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
Here
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-lg-offset-6 col-md-offset-6 col-md-6 col-sm-12">
|
||||
<!-- panel for options -->
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'options'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.optionsList('create','rule-group') }}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn pull-right btn-success">{{ 'store_new_rule_group'|_ }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{ Form.close|raw }}
|
||||
|
||||
|
||||
{% endblock %}
|
Reference in New Issue
Block a user