Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
06376254
Commit
06376254
authored
Oct 26, 2017
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make NamespaceSelect a module
parent
3ddffec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
81 deletions
+59
-81
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+3
-2
app/assets/javascripts/namespace_select.js
app/assets/javascripts/namespace_select.js
+56
-79
No files found.
app/assets/javascripts/dispatcher.js
View file @
06376254
...
@@ -16,7 +16,7 @@ import CILintEditor from './ci_lint_editor';
...
@@ -16,7 +16,7 @@ import CILintEditor from './ci_lint_editor';
/* global GroupsSelect */
/* global GroupsSelect */
/* global Search */
/* global Search */
/* global Admin */
/* global Admin */
/* global NamespaceSelects */
import
NamespaceSelect
from
'
./namespace_select
'
;
/* global NewCommitForm */
/* global NewCommitForm */
/* global NewBranchForm */
/* global NewBranchForm */
/* global Project */
/* global Project */
...
@@ -571,7 +571,8 @@ import Diff from './diff';
...
@@ -571,7 +571,8 @@ import Diff from './diff';
new
UsersSelect
();
new
UsersSelect
();
break
;
break
;
case
'
projects
'
:
case
'
projects
'
:
new
NamespaceSelects
();
document
.
querySelectorAll
(
'
.js-namespace-select
'
)
.
forEach
(
dropdown
=>
new
NamespaceSelect
({
dropdown
}));
break
;
break
;
case
'
labels
'
:
case
'
labels
'
:
switch
(
path
[
2
])
{
switch
(
path
[
2
])
{
...
...
app/assets/javascripts/namespace_select.js
View file @
06376254
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, vars-on-top, one-var-declaration-per-line, comma-dangle, object-shorthand, no-else-return, prefer-template, quotes, prefer-arrow-callback, no-param-reassign, no-cond-assign, max-len */
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, vars-on-top, one-var-declaration-per-line, comma-dangle, object-shorthand, no-else-return, prefer-template, quotes, prefer-arrow-callback, no-param-reassign, no-cond-assign, max-len */
import
Api
from
'
./api
'
;
import
Api
from
'
./api
'
;
(
function
()
{
export
default
class
NamespaceSelect
{
window
.
NamespaceSelect
=
(
function
()
{
constructor
(
opts
)
{
function
NamespaceSelect
(
opts
)
{
this
.
onSelectItem
=
this
.
onSelectItem
.
bind
(
this
);
this
.
onSelectItem
=
this
.
onSelectItem
.
bind
(
this
);
var
fieldName
,
showAny
;
var
fieldName
,
showAny
;
this
.
dropdown
=
$
(
opts
.
dropdown
);
this
.
dropdown
=
opts
.
dropdown
;
showAny
=
true
;
showAny
=
true
;
fieldName
=
'
namespace_id
'
;
fieldName
=
'
namespace_id
'
;
if
(
this
.
dropdown
.
attr
(
'
data-field-name
'
))
{
if
(
this
.
dropdown
.
attr
(
'
data-field-name
'
))
{
fieldName
=
this
.
dropdown
.
data
(
'
fieldName
'
);
fieldName
=
this
.
dropdown
.
data
(
'
fieldName
'
);
}
if
(
this
.
dropdown
.
attr
(
'
data-show-any
'
))
{
showAny
=
this
.
dropdown
.
data
(
'
showAny
'
);
}
this
.
dropdown
.
glDropdown
({
filterable
:
true
,
selectable
:
true
,
filterRemote
:
true
,
search
:
{
fields
:
[
'
path
'
]
},
fieldName
:
fieldName
,
toggleLabel
:
function
(
selected
)
{
if
(
selected
.
id
==
null
)
{
return
selected
.
text
;
}
else
{
return
selected
.
kind
+
"
:
"
+
selected
.
full_path
;
}
},
data
:
function
(
term
,
dataCallback
)
{
return
Api
.
namespaces
(
term
,
function
(
namespaces
)
{
var
anyNamespace
;
if
(
showAny
)
{
anyNamespace
=
{
text
:
'
Any namespace
'
,
id
:
null
};
namespaces
.
unshift
(
anyNamespace
);
namespaces
.
splice
(
1
,
0
,
'
divider
'
);
}
return
dataCallback
(
namespaces
);
});
},
text
:
function
(
namespace
)
{
if
(
namespace
.
id
==
null
)
{
return
namespace
.
text
;
}
else
{
return
namespace
.
kind
+
"
:
"
+
namespace
.
full_path
;
}
},
renderRow
:
this
.
renderRow
,
clicked
:
this
.
onSelectItem
});
}
}
if
(
this
.
dropdown
.
attr
(
'
data-show-any
'
))
{
NamespaceSelect
.
prototype
.
onSelectItem
=
function
(
options
)
{
showAny
=
this
.
dropdown
.
data
(
'
showAny
'
);
const
{
e
}
=
options
;
return
e
.
preventDefault
();
};
return
NamespaceSelect
;
})();
window
.
NamespaceSelects
=
(
function
()
{
function
NamespaceSelects
(
opts
)
{
var
ref
;
if
(
opts
==
null
)
{
opts
=
{};
}
this
.
$dropdowns
=
(
ref
=
opts
.
$dropdowns
)
!=
null
?
ref
:
$
(
'
.js-namespace-select
'
);
this
.
$dropdowns
.
each
(
function
(
i
,
dropdown
)
{
var
$dropdown
;
$dropdown
=
$
(
dropdown
);
return
new
window
.
NamespaceSelect
({
dropdown
:
$dropdown
});
});
}
}
this
.
dropdown
.
glDropdown
({
filterable
:
true
,
selectable
:
true
,
filterRemote
:
true
,
search
:
{
fields
:
[
'
path
'
]
},
fieldName
:
fieldName
,
toggleLabel
:
function
(
selected
)
{
if
(
selected
.
id
==
null
)
{
return
selected
.
text
;
}
else
{
return
selected
.
kind
+
"
:
"
+
selected
.
full_path
;
}
},
data
:
function
(
term
,
dataCallback
)
{
return
Api
.
namespaces
(
term
,
function
(
namespaces
)
{
var
anyNamespace
;
if
(
showAny
)
{
anyNamespace
=
{
text
:
'
Any namespace
'
,
id
:
null
};
namespaces
.
unshift
(
anyNamespace
);
namespaces
.
splice
(
1
,
0
,
'
divider
'
);
}
return
dataCallback
(
namespaces
);
});
},
text
:
function
(
namespace
)
{
if
(
namespace
.
id
==
null
)
{
return
namespace
.
text
;
}
else
{
return
namespace
.
kind
+
"
:
"
+
namespace
.
full_path
;
}
},
renderRow
:
this
.
renderRow
,
clicked
:
this
.
onSelectItem
});
}
return
NamespaceSelects
;
onSelectItem
(
options
)
{
})();
const
{
e
}
=
options
;
}).
call
(
window
);
return
e
.
preventDefault
();
}
}
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