Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
27cdf066
Commit
27cdf066
authored
Feb 01, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.task-on.com:ktask/task-on.com
parents
bf29c8f9
e9a78af8
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
189 additions
and
4 deletions
+189
-4
backend/web/js/triggers/conditions/admin-block.js
backend/web/js/triggers/conditions/admin-block.js
+28
-0
common/modules/triggers/components/conditions/Conditions.php
common/modules/triggers/components/conditions/Conditions.php
+19
-2
common/modules/triggers/components/conditions/conditions/CheckClickingOnTheLink.php
...mponents/conditions/conditions/CheckClickingOnTheLink.php
+19
-0
common/modules/triggers/components/conditions/config/main.php
...on/modules/triggers/components/conditions/config/main.php
+10
-1
common/modules/triggers/controllers/TriggerAdminController.php
...n/modules/triggers/controllers/TriggerAdminController.php
+21
-0
common/modules/triggers/forms/TriggerForm.php
common/modules/triggers/forms/TriggerForm.php
+22
-1
common/modules/triggers/models/TriggerTrigger.php
common/modules/triggers/models/TriggerTrigger.php
+3
-0
common/modules/triggers/views/trigger-admin/condition-html.php
...n/modules/triggers/views/trigger-admin/condition-html.php
+10
-0
console/migrations/m160201_134526_trigger_params_table.php
console/migrations/m160201_134526_trigger_params_table.php
+57
-0
No files found.
backend/web/js/triggers/conditions/admin-block.js
0 → 100644
View file @
27cdf066
$
(
document
).
on
(
'
click
'
,
'
a.add_condition
'
,
function
()
{
var
id
=
$
(
this
).
data
(
'
id
'
);
var
container
=
$
(
this
).
closest
(
'
div.btn-group
'
).
parent
().
children
(
'
div.conditions-block
'
);
$
.
ajax
({
url
:
'
/triggers/trigger-admin/getconditionhtml
'
,
data
:
{
id
:
id
},
method
:
'
GET
'
,
success
:
function
(
response
)
{
var
result
=
JSON
.
parse
(
response
);
container
.
append
(
result
);
}
})
});
$
(
document
).
on
(
'
click
'
,
'
button.add-and-condition
'
,
function
()
{
var
container
=
$
(
this
).
closest
(
'
table
'
).
children
(
'
tbody
'
);
$
.
ajax
({
url
:
'
/triggers/trigger-admin/getandconditionhtml
'
,
success
:
function
(
response
)
{
var
result
=
JSON
.
parse
(
response
);
container
.
append
(
result
);
}
})
});
common/modules/triggers/components/conditions/Conditions.php
View file @
27cdf066
...
...
@@ -65,8 +65,9 @@ class Conditions {
*/
public
function
getConditions
(){
$data
=
array
();
foreach
(
self
::
$config
as
$condition
)
{
foreach
(
self
::
$config
as
$
key
=>
$
condition
)
{
$class
=
$condition
[
'class'
]
::
init
();
$class
->
config
=
self
::
$config
[
$key
];
$data
[
$class
::
CONDITION_ID
]
=
$class
;
}
return
$data
;
...
...
@@ -78,11 +79,27 @@ class Conditions {
* @return null
*/
public
function
getConditionById
(
$id
){
foreach
(
self
::
$config
as
$condition
)
{
foreach
(
self
::
$config
as
$
key
=>
$
condition
)
{
$class
=
$condition
[
'class'
]
::
init
();
$class
->
config
=
self
::
$config
[
$key
];
if
(
$class
::
CONDITION_ID
==
$id
)
return
$class
;
}
return
null
;
}
/**
* @return string
*/
public
function
getControlArea
(){
$html
=
'<div class="conditions-block"></div>'
;
$html
.=
'<div class="btn-group" role="group">'
;
$html
.=
'<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-plus"></i></button>'
;
$html
.=
'<ul class="dropdown-menu">'
;
foreach
(
Conditions
::
init
()
->
getConditions
()
as
$id
=>
$condition
)
$html
.=
'<li><a href="#" data-id="'
.
$id
.
'" class="add_condition">'
.
$condition
->
getName
()
.
'</a></li>'
;
$html
.=
'</ul>'
;
$html
.=
'</div>'
;
return
$html
;
}
}
\ No newline at end of file
common/modules/triggers/components/conditions/conditions/CheckClickingOnTheLink.php
0 → 100644
View file @
27cdf066
<?php
namespace
common\modules\triggers\components\conditions\conditions
;
use
common\modules\triggers\components\conditions\vendor\ConditionBase
;
use
common\modules\triggers\components\conditions\vendor\ConditionInterface
;
class
CheckClickingOnTheLink
extends
ConditionBase
implements
ConditionInterface
{
const
CONDITION_ID
=
2
;
public
$name
=
'Был произведен переход по ссылке'
;
/**
* @param null|string $conditionName
* @return $this mixed
*/
public
static
function
init
(
$conditionName
=
__CLASS__
){
return
parent
::
init
(
$conditionName
);
}
}
\ No newline at end of file
common/modules/triggers/components/conditions/config/main.php
View file @
27cdf066
<?php
return
[
'check-email-to-opening'
=>
[
'class'
=>
'common\modules\triggers\components\conditions\conditions\CheckEmailToOpening'
'class'
=>
'common\modules\triggers\components\conditions\conditions\CheckEmailToOpening'
,
],
'check-clicking-on-the-link'
=>
[
'class'
=>
'common\modules\triggers\components\conditions\conditions\CheckClickingOnTheLink'
,
'params'
=>
[
'link'
=>
[
'placeholder'
=>
'Ссылка'
,
'type'
=>
'text'
]
]
]
];
\ No newline at end of file
common/modules/triggers/controllers/TriggerAdminController.php
View file @
27cdf066
...
...
@@ -8,10 +8,13 @@
namespace
common\modules\triggers\controllers
;
use
common\modules\triggers\components\conditions\Conditions
;
use
common\modules\triggers\components\conditions\vendor\ConditionBase
;
use
Yii
;
use
common\components\AdminController
;
use
common\modules\triggers\models\TriggerTrigger
;
use
yii\data\ActiveDataProvider
;
use
yii\helpers\Json
;
use
yii\web\NotFoundHttpException
;
class
TriggerAdminController
extends
AdminController
{
...
...
@@ -24,11 +27,29 @@ class TriggerAdminController extends AdminController {
'Create'
=>
'Добавление триггера'
,
'Update'
=>
'Редактирование триггера'
,
'Delete'
=>
'Удаление триггера'
,
'Getconditionhtml'
=>
'Получаем html блок с условием'
,
'Getandconditionhtml'
=>
'Получаем html новой строки с условиями'
,
'Testing'
=>
'Testing page'
];
}
public
function
actionGetandconditionhtml
(){
return
Json
::
encode
(
'<tr><td>'
.
Conditions
::
init
()
->
getControlArea
()
.
'</td></tr>'
);
}
public
function
actionGetconditionhtml
(
$id
){
$condition
=
Conditions
::
init
()
->
getConditionById
(
$id
);
$result
=
$this
->
renderPartial
(
'condition-html'
,
[
'object'
=>
$condition
]
);
return
Json
::
encode
(
$result
);
}
public
function
actionTesting
(){
return
$this
->
render
(
'testing'
...
...
common/modules/triggers/forms/TriggerForm.php
View file @
27cdf066
<?php
use
\common\modules\triggers\components\conditions\Conditions
;
Yii
::
$app
->
controller
->
view
->
registerJsFile
(
'/js/triggers/conditions/admin-block.js'
);
// Формируем html будущей таблицы, открыли тег
$table
=
'<table class="table table-bordered">'
;
// Формируем тело будущей таблицы
$table
.=
'<tbody>'
;
$table
.=
'<tr>'
;
$table
.=
'<td>'
.
Conditions
::
init
()
->
getControlArea
()
.
'</td>'
;
$table
.=
'<tr>'
;
$table
.=
'</tbody>'
;
// Формируем футер
$table
.=
'<tfoot>'
;
$table
.=
'<td><button type="button" class="btn btn-primary add-and-condition">Добавить условие "И"</button></td>'
;
$table
.=
'</tfoot>'
;
// Закрываем таблицу
$table
.=
'</table>'
;
return
[
'activeForm'
=>
[
'id'
=>
'trigger-form'
],
'elements'
=>
[
'table'
=>
$table
,
'active'
=>
[
'type'
=>
'checkbox'
],
...
...
@@ -13,7 +34,7 @@ return [
],
'name'
=>
[
'type'
=>
'text'
,
'class'
=>
'form-control'
'class'
=>
'form-control'
,
],
'description'
=>
[
'type'
=>
'textarea'
,
...
...
common/modules/triggers/models/TriggerTrigger.php
View file @
27cdf066
...
...
@@ -23,6 +23,8 @@ use common\modules\users\models\User;
*/
class
TriggerTrigger
extends
\yii\db\ActiveRecord
{
public
$conditions
;
/**
* @inheritdoc
*/
...
...
@@ -60,6 +62,7 @@ class TriggerTrigger extends \yii\db\ActiveRecord
'date_create'
=>
'Дата создания'
,
'timeout'
=>
'Задержка перед выполнением (секунд)'
,
'message_template_id'
=>
'Шаблон письма'
,
'conditions'
=>
'Шаблон письма'
,
];
}
...
...
common/modules/triggers/views/trigger-admin/condition-html.php
0 → 100644
View file @
27cdf066
<?php
use
\common\modules\triggers\components\conditions\Conditions
;
?>
<div
class=
"alert alert-info alert-dismissible"
role=
"alert"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<strong>
Условие:
<?php
echo
$object
->
getName
();
?>
</strong>
<?php
foreach
(
$object
->
getParams
()
as
$param
)
{
echo
$param
;
}
?>
</div>
\ No newline at end of file
console/migrations/m160201_134526_trigger_params_table.php
0 → 100644
View file @
27cdf066
<?php
use
yii\db\Migration
;
use
yii\db\Schema
;
class
m160201_134526_trigger_params_table
extends
Migration
{
// public function up()
// {
//
// }
//
// public function down()
// {
// echo "m160201_134526_trigger_params_table cannot be reverted.\n";
//
// return false;
// }
// Use safeUp/safeDown to run migration code within a transaction
public
function
safeUp
()
{
$this
->
createTable
(
'trigger_param'
,
[
'id'
=>
Schema
::
TYPE_PK
,
'condition_id'
=>
Schema
::
TYPE_INTEGER
.
' NOT NULL'
,
'key'
=>
Schema
::
TYPE_TEXT
,
'value'
=>
Schema
::
TYPE_TEXT
]
);
$this
->
addColumn
(
'trigger_condition'
,
'condition_id'
,
Schema
::
TYPE_INTEGER
.
' NOT NULL'
);
$this
->
addForeignKey
(
'fk_trigger_param_condition'
,
'trigger_param'
,
'condition_id'
,
'trigger_condition'
,
'id'
);
}
public
function
safeDown
()
{
$this
->
dropForeignKey
(
'fk_trigger_param_condition'
,
'trigger_param'
);
$this
->
dropColumn
(
'trigger_condition'
,
'condition_id'
);
$this
->
dropTable
(
'trigger_param'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment