Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
9c28d279
Commit
9c28d279
authored
Nov 30, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter interface
get_diff_array function
parent
2aa8040c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
179 additions
and
69 deletions
+179
-69
multiselect.html
app/shared/templates/multiselect.html
+62
-0
nodeTable.html
app/shared/templates/nodeTable.html
+44
-44
form_service.js
app/zetalib/form_service.js
+73
-25
No files found.
app/shared/templates/multiselect.html
0 → 100644
View file @
9c28d279
<div
class=
"form-group {{form.htmlClass}} schema-form-select col-md-12"
ng-class=
"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess(), 'has-feedback': form.feedback !== false}"
>
<div
class=
"col-md-8"
>
<label
class=
"control-label {{form.labelHtmlClass}}"
ng-show=
"showTitle()"
>
{{form.title}}
</label>
<div
class=
"row"
>
<div
class=
"form-group input-group"
>
<input
type=
"text"
placeholder=
"{{form.title}} filtrele"
class=
"form-control {{form.fieldHtmlClass}}"
name=
"filter-interface"
ng-model=
"form.filterValue"
ng-keyup=
"form.appendFiltered(form.filterValue)"
/>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-5"
>
<label
for=
"filterItems"
>
{{form.title}} Liste
</label>
<select
ng-model=
"selectedItemsModel"
value=
"$$value$$"
ng-model-options=
"form.ngModelOptions"
ng-disabled=
"form.readonly"
sf-changed=
"form"
class=
"form-control {{form.fieldHtmlClass}}"
schema-validate=
"form"
ng-options=
"item as item.name for item in form.filteredItems"
name=
"filterItems"
multiple
>
</select>
</div>
<div
class=
"col-md-1"
>
<a
href=
"javascript:void(0)"
ng-click=
"form.select(selectedItemsModel)"
><i
class=
"fa fa-arrow-right fa-fw"
></i></a><br>
<a
href=
"javascript:void(0)"
ng-click=
"form.deselect(selectedFilteredItemsModel)"
><i
class=
"fa fa-arrow-left fa-fw"
></i></a>
</div>
<div
class=
"col-md-5"
>
<label
for=
"selectedItems"
>
Seçilenler
</label>
<select
ng-model=
"selectedFilteredItemsModel"
value=
"$$value$$"
ng-model-options=
"form.ngModelOptions"
ng-disabled=
"form.readonly"
sf-changed=
"form"
class=
"form-control {{form.fieldHtmlClass}}"
schema-validate=
"form"
ng-options=
"item as item.name for item in form.selectedFilteredItems"
name=
"selectedItems"
multiple
>
</select>
</div>
</div>
<div
class=
"help-block"
sf-message=
"form.description"
></div>
</div>
<div
class=
"col-md-4"
>
<a
href=
"javascript:void(0);"
add-modal-for-linked-model
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</div>
</div>
\ No newline at end of file
app/shared/templates/nodeTable.html
View file @
9c28d279
<div
class=
"tablescroll"
>
<table
class=
"table table-bordered"
style=
"background-color:#fff;"
>
<thead>
<tr
ng-if=
"node.schema.formType=='Node'"
>
<!--<div class="tablescroll">-->
<!--<table class="table table-bordered" style="background-color:#fff;">-->
<!--<thead>-->
<!--<tr ng-if="node.schema.formType=='Node'">-->
<!--<!–<th colspan="2">–>-->
<!--<!–<label>–>-->
<!--<!–<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">–>-->
<!--<!–Hepsini Seç–>-->
<!--<!–</label>–>-->
<!--<!–</th>–>-->
<!--<th ng-repeat="(key,value) in node.model">{{ key }}</th>-->
<!--<th>İşlem</th>-->
<!--</tr>-->
<!--<tr ng-if="node.schema.formType=='ListNode'">-->
<!--<th colspan="2">-->
<!--<label>-->
<!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
<!--Hepsini Seç-->
<!--</label>-->
<!--</th>-->
<th
ng-repeat=
"(key,value) in node.model"
>
{{ key }}
</th>
<th>
İşlem
</th>
</tr>
<tr
ng-if=
"node.schema.formType=='ListNode'"
>
<th
colspan=
"2"
>
<label>
<input
type=
"checkbox"
style=
"zoom:1.5; margin:5px 0 0 8px;"
>
Hepsini Seç
</label>
</th>
<th
ng-repeat=
"(key,value) in node.model[0]"
>
{{ key }}
</th>
<th>
İşlem
</th>
</tr>
</thead>
<tbody
ng-class=
"{hidden: node.lengthModels < 1}"
>
<!--<th ng-repeat="(key,value) in node.model[0]">{{ key }}</th>-->
<!--<th>İşlem</th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody ng-class="{hidden: node.lengthModels < 1}">-->
<tr
ng-if=
"node.schema.formType=='Node'"
>
<!--<tr ng-if="node.schema.formType=='Node'">-->
<!--<!–<td width="60">–>-->
<!--<!–<label>–>-->
<!--<!–<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">–>-->
<!--<!–</label>–>-->
<!--<!–</td>–>-->
<!--<!–<th scope="row" style="text-align:center">1</th>–>-->
<!--<td ng-repeat="value in node.model">{{ value }}</td>-->
<!--<td>-->
<!--<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Düzenle</button><br>-->
<!--<button>Sil</button>-->
<!--</td>-->
<!--</tr>-->
<!--<tr ng-repeat="listnodemodel in node.model" ng-if="node.schema.formType=='ListNode'">-->
<!--<td width="60">-->
<!--<label>-->
<!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
<!--</label>-->
<!--</td>-->
<!--<th scope="row" style="text-align:center">1</th>-->
<td
ng-repeat=
"value in node.model"
>
{{ value }}
</td>
<td>
<button
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit"
>
Düzenle
</button><br>
<button>
Sil
</button>
</td>
</tr>
<tr
ng-repeat=
"listnodemodel in node.model"
ng-if=
"node.schema.formType=='ListNode'"
>
<td
width=
"60"
>
<label>
<input
type=
"checkbox"
style=
"zoom:1.5; margin:5px 0 0 8px;"
>
</label>
</td>
<th
scope=
"row"
style=
"text-align:center"
>
{{$index+1}}
</th>
<td
ng-repeat=
"(k, v) in listnodemodel"
>
{{ v }}
</td>
<td>
<button
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}"
>
Düzenle
</button><br>
<button>
Sil
</button>
</td>
</tr>
<!--<th scope="row" style="text-align:center">{{$index+1}}</th>-->
<!--<td ng-repeat="(k, v) in listnodemodel">{{ v }}</td>-->
<!--<td>-->
<!--<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}">Düzenle</button><br>-->
<!--<button>Sil</button>-->
<!--</td>-->
<!--</tr>-->
</tbody>
</table>
</div>
\ No newline at end of file
<!--</tbody>-->
<!--</table>-->
<!--</div>-->
\ No newline at end of file
app/zetalib/form_service.js
View file @
9c28d279
...
...
@@ -100,6 +100,8 @@ angular.module('formService', ['ui.bootstrap'])
*/
generator
.
prepareFormItems
=
function
(
scope
)
{
//scope.schema.properties.Permissions ? scope.schema.properties.Permissions['widget']='filter_interface':true;
// todo: remove after backend fix
angular
.
forEach
(
scope
.
form
,
function
(
value
,
key
)
{
if
(
value
.
type
===
'select'
)
{
...
...
@@ -157,10 +159,14 @@ angular.module('formService', ['ui.bootstrap'])
if
(
scope
.
modalElements
)
{
scope
.
submitModalForm
();
}
else
{
scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
scope
[
workOnForm
].
$valid
)
{
if
(
v
.
validation
===
false
)
{
generator
.
submit
(
scope
,
redirectTo
);
scope
.
$broadcast
(
'disposeModal'
);
}
else
{
scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
scope
[
workOnForm
].
$valid
)
{
generator
.
submit
(
scope
,
redirectTo
);
scope
.
$broadcast
(
'disposeModal'
);
}
}
}
}
...
...
@@ -225,15 +231,14 @@ angular.module('formService', ['ui.bootstrap'])
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
k
)];
var
modelScope
=
{
"url"
:
v
.
wf
,
"form_params"
:
{
model
:
v
.
model_name
,
cmd
:
v
.
list_cmd
}};
scope
.
$on
(
'refreshTitleMap'
,
function
(
event
,
data
)
{
//
scope.$on('refreshTitleMap', function (event, data) {
// todo: write a function to refresh titleMap after new item add to linkedModel
});
//
});
scope
.
generateTitleMap
=
function
(
modelScope
)
{
generator
.
get_list
(
modelScope
).
then
(
function
(
res
)
{
formitem
.
titleMap
=
[];
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
)
{
debugger
;
if
(
item
!==
"-1"
)
{
formitem
.
titleMap
.
push
({
"value"
:
item
.
key
,
...
...
@@ -276,25 +281,12 @@ angular.module('formService', ['ui.bootstrap'])
scope
.
form
[
scope
.
form
.
indexOf
(
k
)]
=
formitem
;
}
if
(
v
.
type
===
'filter_interface'
)
{
if
((
v
.
type
===
'ListNode'
||
v
.
type
===
'Node'
)
&&
v
.
widget
===
'filter_interface'
)
{
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
k
)];
var
modelscope
=
{
"url"
:
v
.
wf
,
"form_params"
:
{
model
:
v
.
model_name
,
cmd
:
v
.
list_cmd
}};
scope
.
$on
(
'refreshTitleMap'
,
function
(
event
,
data
)
{
// todo: write a function to refresh titleMap after new item add to linkedModel
});
var
modelScope
=
{
"url"
:
v
.
wf
||
scope
.
wf
,
"form_params"
:
{
model
:
v
.
model_name
||
v
.
schema
[
0
].
model_name
,
cmd
:
v
.
list_cmd
||
'select_list'
}};
formitem
=
{
type
:
"template"
,
templateUrl
:
"shared/templates/multiselect.html"
,
title
:
v
.
title
,
wf
:
v
.
wf
,
add_cmd
:
v
.
add_cmd
,
name
:
v
.
model_name
,
model_name
:
v
.
model_name
,
selected_item
:
{},
titleMap
:
generator
.
get_list
(
modelscope
).
then
(
function
(
res
)
{
scope
.
generateTitleMap
=
function
(
modelScope
)
{
generator
.
get_list
(
modelScope
).
then
(
function
(
res
)
{
formitem
.
titleMap
=
[];
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
)
{
if
(
item
!==
"-1"
)
{
...
...
@@ -314,20 +306,66 @@ angular.module('formService', ['ui.bootstrap'])
angular
.
element
(
document
.
querySelector
(
'input[name='
+
v
.
model_name
+
']'
)).
val
(
formitem
.
selected_item
.
name
);
}
);
}),
})
};
formitem
=
{
type
:
"template"
,
templateUrl
:
"shared/templates/multiselect.html"
,
title
:
v
.
title
,
wf
:
v
.
wf
,
add_cmd
:
v
.
add_cmd
,
name
:
v
.
model_name
,
model_name
:
v
.
model_name
,
filterValue
:
''
,
selected_item
:
{},
filteredItems
:
[],
selectedFilteredItems
:
[],
titleMap
:
scope
.
generateTitleMap
(
modelScope
),
onSelect
:
function
(
item
)
{
scope
.
model
[
k
]
=
item
.
value
;
},
onDropdownSelect
:
function
(
item
,
inputname
)
{
scope
.
model
[
k
]
=
item
.
value
;
jQuery
(
'input[name='
+
inputname
+
']'
).
val
(
item
.
name
);
},
appendFiltered
:
function
(
filterValue
)
{
formitem
.
filteredItems
=
[];
if
(
filterValue
.
length
>
2
)
{
angular
.
forEach
(
formitem
.
titleMap
,
function
(
value
,
key
)
{
if
(
value
.
name
.
indexOf
(
filterValue
)
>
-
1
)
{
formitem
.
filteredItems
.
push
(
formitem
.
titleMap
[
key
]);
}
});
}
formitem
.
filteredItems
=
generator
.
get_diff_array
(
formitem
.
filteredItems
,
formitem
.
selectedFilteredItems
);
},
select
:
function
(
selectedItemsModel
)
{
formitem
.
selectedFilteredItems
=
formitem
.
selectedFilteredItems
.
concat
(
selectedItemsModel
);
formitem
.
appendFiltered
(
formitem
.
filterValue
);
scope
.
model
[
k
]
=
formitem
.
dataToModel
(
selectedItemsModel
);
},
deselect
:
function
(
selectedFilteredItemsModel
)
{
formitem
.
selectedFilteredItems
=
generator
.
get_diff_array
(
formitem
.
selectedFilteredItems
,
selectedFilteredItemsModel
);
formitem
.
appendFiltered
(
formitem
.
filterValue
);
scope
.
model
[
k
]
=
formitem
.
dataToModel
(
formitem
.
selectedFilteredItems
);
},
dataToModel
:
function
(
data
)
{
var
dataValues
=
[];
angular
.
forEach
(
data
,
function
(
value
,
key
)
{
var
dataKey
=
{};
dataKey
[
v
.
schema
[
0
].
name
]
=
value
.
value
;
dataValues
.
push
(
dataKey
);
});
return
dataValues
;
}
};
scope
.
form
[
scope
.
form
.
indexOf
(
k
)]
=
formitem
;
}
if
(
v
.
type
===
'ListNode'
||
v
.
type
===
'Nod
e'
)
{
if
(
(
v
.
type
===
'ListNode'
||
v
.
type
===
'Node'
)
&&
v
.
widget
!==
'filter_interfac
e'
)
{
scope
[
v
.
type
]
=
scope
[
v
.
type
]
||
{};
...
...
@@ -574,6 +612,16 @@ angular.module('formService', ['ui.bootstrap'])
return
result
;
};
generator
.
get_diff_array
=
function
(
array1
,
array2
)
{
var
result
=
[];
angular
.
forEach
(
array1
,
function
(
value
,
key
)
{
if
(
array2
.
indexOf
(
value
)
<
0
)
{
result
.
push
(
value
);
}
});
return
result
;
};
/**
* submit function is general function for submiting forms
* @param $scope
...
...
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