Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
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
dataplatform
atlas
Commits
72243644
Commit
72243644
authored
Nov 12, 2019
by
kevalbhatt
Committed by
nixonrodrigues
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3521 : UI: Use existing labels from other entities
Signed-off-by:
nixonrodrigues
<
nixon@apache.org
>
parent
1b5ca4c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
15 deletions
+69
-15
EntityLabelDefineView.js
dashboardv2/public/js/views/entity/EntityLabelDefineView.js
+35
-8
EntityLabelDefineView.js
dashboardv3/public/js/views/entity/EntityLabelDefineView.js
+34
-7
No files found.
dashboardv2/public/js/views/entity/EntityLabelDefineView.js
View file @
72243644
...
...
@@ -23,8 +23,9 @@ define(['require',
'utils/Utils'
,
'utils/Messages'
,
'utils/Enums'
,
'utils/UrlLinks'
,
'utils/CommonViewFunction'
,
],
function
(
require
,
Backbone
,
EntityLabelDefineView_tmpl
,
VEntity
,
Utils
,
Messages
,
Enums
,
CommonViewFunction
)
{
],
function
(
require
,
Backbone
,
EntityLabelDefineView_tmpl
,
VEntity
,
Utils
,
Messages
,
Enums
,
UrlLinks
,
CommonViewFunction
)
{
'use strict'
;
return
Backbone
.
Marionette
.
LayoutView
.
extend
({
...
...
@@ -72,16 +73,42 @@ define(['require',
return
"<option selected > "
+
label
+
" </option>"
;
});
this
.
ui
.
addLabelOptions
.
html
(
str
);
var
getLabelData
=
function
(
data
,
selectedData
)
{
if
(
data
.
suggestions
)
{
return
_
.
map
(
data
.
suggestions
,
function
(
name
,
index
)
{
var
findValue
=
_
.
find
(
selectedData
,
{
id
:
name
})
if
(
findValue
)
{
return
findValue
;
}
else
{
return
{
id
:
name
,
text
:
name
}
}
});
}
else
{
return
[]
}
};
this
.
ui
.
addLabelOptions
.
select2
({
placeholder
:
"Select Label"
,
allowClear
:
false
,
tags
:
true
,
multiple
:
true
,
matcher
:
function
(
params
,
data
)
{
if
(
params
.
term
===
data
.
text
)
{
return
data
;
}
return
null
;
ajax
:
{
url
:
UrlLinks
.
searchApiUrl
(
'suggestions'
),
dataType
:
'json'
,
delay
:
250
,
data
:
function
(
params
)
{
return
{
prefixString
:
_
.
escape
(
params
.
term
),
// search term
fieldName
:
'__labels'
};
},
processResults
:
function
(
data
,
params
)
{
return
{
results
:
getLabelData
(
data
,
this
.
$element
.
select2
(
"data"
))
};
},
cache
:
true
},
templateResult
:
this
.
formatResultSearch
});
...
...
@@ -91,7 +118,7 @@ define(['require',
return
state
.
text
;
}
if
(
!
state
.
element
)
{
return
$
(
"<span>Add<strong> '"
+
state
.
text
+
"'</strong></span>"
);
return
$
(
"<span>Add<strong> '"
+
_
.
escape
(
state
.
text
)
+
"'</strong></span>"
);
}
},
onChangeLabelChange
:
function
()
{
...
...
@@ -116,7 +143,7 @@ define(['require',
type
:
'POST'
,
success
:
function
()
{
var
msg
=
entityJson
.
labels
===
undefined
?
'addSuccessMessage'
:
'editSuccessMessage'
,
caption
=
"One or more label"
;
caption
=
"One or more label"
;
if
(
payload
.
length
===
0
)
{
msg
=
'removeSuccessMessage'
;
caption
=
"One or more existing label"
;
...
...
dashboardv3/public/js/views/entity/EntityLabelDefineView.js
View file @
72243644
...
...
@@ -23,8 +23,9 @@ define(['require',
'utils/Utils'
,
'utils/Messages'
,
'utils/Enums'
,
'utils/UrlLinks'
,
'utils/CommonViewFunction'
,
],
function
(
require
,
Backbone
,
EntityLabelDefineView_tmpl
,
VEntity
,
Utils
,
Messages
,
Enums
,
CommonViewFunction
)
{
],
function
(
require
,
Backbone
,
EntityLabelDefineView_tmpl
,
VEntity
,
Utils
,
Messages
,
Enums
,
UrlLinks
,
CommonViewFunction
)
{
'use strict'
;
return
Backbone
.
Marionette
.
LayoutView
.
extend
({
...
...
@@ -72,16 +73,42 @@ define(['require',
return
"<option selected > "
+
label
+
" </option>"
;
});
this
.
ui
.
addLabelOptions
.
html
(
str
);
var
getLabelData
=
function
(
data
,
selectedData
)
{
if
(
data
.
suggestions
)
{
return
_
.
map
(
data
.
suggestions
,
function
(
name
,
index
)
{
var
findValue
=
_
.
find
(
selectedData
,
{
id
:
name
})
if
(
findValue
)
{
return
findValue
;
}
else
{
return
{
id
:
name
,
text
:
name
}
}
});
}
else
{
return
[]
}
};
this
.
ui
.
addLabelOptions
.
select2
({
placeholder
:
"Select Label"
,
allowClear
:
false
,
tags
:
true
,
multiple
:
true
,
matcher
:
function
(
params
,
data
)
{
if
(
params
.
term
===
data
.
text
)
{
return
data
;
}
return
null
;
ajax
:
{
url
:
UrlLinks
.
searchApiUrl
(
'suggestions'
),
dataType
:
'json'
,
delay
:
250
,
data
:
function
(
params
)
{
return
{
prefixString
:
_
.
escape
(
params
.
term
),
// search term
fieldName
:
'__labels'
};
},
processResults
:
function
(
data
,
params
)
{
return
{
results
:
getLabelData
(
data
,
this
.
$element
.
select2
(
"data"
))
};
},
cache
:
true
},
templateResult
:
this
.
formatResultSearch
});
...
...
@@ -91,7 +118,7 @@ define(['require',
return
state
.
text
;
}
if
(
!
state
.
element
)
{
return
$
(
"<span>Add<strong> '"
+
state
.
text
+
"'</strong></span>"
);
return
$
(
"<span>Add<strong> '"
+
_
.
escape
(
state
.
text
)
+
"'</strong></span>"
);
}
},
onChangeLabelChange
:
function
()
{
...
...
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