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
7fb39794
Commit
7fb39794
authored
Apr 15, 2016
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quick add widget for listnodes
rfix #5269
parent
287e49d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
6 deletions
+99
-6
crud_widgets.js
app/components/crud/crud_widgets.js
+76
-0
form.html
app/components/crud/templates/form.html
+6
-5
nodeTable.html
app/components/crud/templates/nodeTable.html
+2
-1
quick_add.html
app/components/crud/templates/quick_add.html
+15
-0
No files found.
app/components/crud/crud_widgets.js
0 → 100644
View file @
7fb39794
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*
* @author Evren Kutar
*/
angular
.
module
(
'ulakbus.crud'
)
.
directive
(
'quickAdd'
,
function
(
Generator
)
{
return
{
templateUrl
:
'components/crud/templates/quick_add.html'
,
restrict
:
'E'
,
replace
:
true
,
scope
:
{
node
:
'='
},
controller
:
function
(
$scope
)
{
$scope
.
kw
=
''
;
$scope
.
getTitleMap
=
function
()
{
return
$scope
.
generateTitleMap
(
$scope
.
kw
);
};
$scope
.
generateTitleMap
=
function
(
kw
)
{
var
searchData
=
{
form_params
:
{
model
:
$scope
.
node
.
quick_add_model
,
wf
:
'crud'
,
query
:
kw
,
cmd
:
'object_search'
}
};
if
(
angular
.
isDefined
(
$scope
.
$parent
.
form_params
.
param
)){
searchData
.
form_params
[
'id'
]
=
$scope
.
$parent
.
form_params
.
id
;
}
return
Generator
.
get_list
(
searchData
).
then
(
function
(
res
)
{
var
titleMap
=
[];
angular
.
forEach
(
res
.
objects
,
function
(
item
)
{
titleMap
.
push
({
"value"
:
item
[
0
],
"name"
:
item
[
1
]
});
});
return
titleMap
;
});
};
$scope
.
onSelect
=
function
(
item
)
{
// add to listnode here
// field default is node schema properties first index
var
get_first_key
=
function
()
{
return
Object
.
keys
(
$scope
.
node
.
schema
.
properties
)[
0
];
};
var
field
=
$scope
.
node
.
quick_add_field
||
get_first_key
();
var
f
=
{
key
:
item
.
value
};
f
[
field
]
=
item
.
name
;
// loop item keys and if a key not found in f add it with no value
angular
.
forEach
(
$scope
.
node
.
items
[
0
],
function
(
value
,
key
)
{
if
(
!
angular
.
isDefined
(
f
[
key
]))
{
f
[
key
]
=
undefined
;
}
});
try
{
angular
.
forEach
(
$scope
.
node
.
items
,
function
(
value
,
key
)
{
if
(
value
[
'key'
]
===
item
.
value
)
{
throw
Error
();
}
});
$scope
.
node
.
model
.
push
(
f
);
$scope
.
node
.
items
.
push
(
f
);
}
catch
(
e
)
{
alert
(
'bu öğe listede zaten mevcut!!'
);
}
}
}}
});
\ No newline at end of file
app/components/crud/templates/form.html
View file @
7fb39794
...
...
@@ -20,11 +20,12 @@
</div>
<div
ng-repeat=
"node in ListNode"
>
<h3>
{{ node.title }}
<span
ng-if=
"meta.allow_add_listnode !== false"
>
<a
modal-for-nodes=
"{{node.schema.model_name}},ListNode,add"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
<span
ng-if=
"meta.allow_add_listnode !== false"
ng-hide=
"node.quick_add === true"
>
<a
modal-for-nodes=
"{{node.schema.model_name}},ListNode,add"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
<quick-add
node=
"node"
ng-if=
"node.quick_add === true"
></quick-add>
</h3>
<div
class=
"list-node-table"
ng-if=
"!meta.translate_widget"
>
...
...
app/components/crud/templates/nodeTable.html
View file @
7fb39794
...
...
@@ -66,7 +66,8 @@
</td>
<td
ng-if=
"meta.allow_actions!==false"
>
<div
ng-hide=
"meta.object_actions.length > 0"
>
<span
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}"
>
<span
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}"
ng-hide=
"node.quick_add === true"
>
<i
class=
"fa fa-pencil-square-o fa-fw"
></i>
</span>
<span
ng-click=
"remove(node, 'ListNode', $index)"
><i
class=
"fa fa-times fa-fw"
></i></span>
...
...
app/components/crud/templates/quick_add.html
0 → 100644
View file @
7fb39794
<div>
<input
class=
"form-control"
type=
"text"
placeholder=
"eklemek istediğiniz nesneyi yazınız..."
ng-model=
"kw"
uib-typeahead=
"item as item.name for item in getTitleMap($viewValue)"
typeahead-on-select=
"onSelect($item)"
typeahead-loading=
"loadingTitleMap"
typeahead-no-results=
"noResults"
typeahead-wait-ms=
"500"
/>
<div
ng-show=
"loadingTitleMap"
class=
"loader"
></div>
<div
ng-show=
"noResults"
>
<i
class=
"fa fa-close"
></i>
bulunamadı.
</div>
</div>
\ No newline at end of file
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