Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
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
PSDI Army
yii2
Commits
4cb1a264
Commit
4cb1a264
authored
Oct 30, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1104. Model generator table names auto complete.
parent
6559b06e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
1 deletion
+107
-1
Generator.php
framework/yii/gii/Generator.php
+11
-0
GiiAsset.php
framework/yii/gii/GiiAsset.php
+2
-0
main.css
framework/yii/gii/assets/main.css
+8
-0
typeahead.js
framework/yii/gii/assets/typeahead.js
+0
-0
typeahead.js-bootstrap.css
framework/yii/gii/assets/typeahead.js-bootstrap.css
+51
-0
ActiveField.php
framework/yii/gii/components/ActiveField.php
+23
-1
Generator.php
framework/yii/gii/generators/model/Generator.php
+12
-0
No files found.
framework/yii/gii/Generator.php
View file @
4cb1a264
...
@@ -111,6 +111,17 @@ abstract class Generator extends Model
...
@@ -111,6 +111,17 @@ abstract class Generator extends Model
}
}
/**
/**
* Returns the list of auto complete values.
* The array keys are the attribute names, and the array values are the corresponding auto complete values.
* Auto complete values can also be callable typed in order one want to make postponed data generation.
* @return array the list of auto complete values
*/
public
function
autoCompleteData
()
{
return
[];
}
/**
* Returns the message to be displayed when the newly generated code is saved successfully.
* Returns the message to be displayed when the newly generated code is saved successfully.
* Child classes may override this method to customize the message.
* Child classes may override this method to customize the message.
* @return string the message to be displayed when the newly generated code is saved successfully.
* @return string the message to be displayed when the newly generated code is saved successfully.
...
...
framework/yii/gii/GiiAsset.php
View file @
4cb1a264
...
@@ -26,12 +26,14 @@ class GiiAsset extends AssetBundle
...
@@ -26,12 +26,14 @@ class GiiAsset extends AssetBundle
*/
*/
public
$css
=
[
public
$css
=
[
'main.css'
,
'main.css'
,
'typeahead.js-bootstrap.css'
,
];
];
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
public
$js
=
[
public
$js
=
[
'gii.js'
,
'gii.js'
,
'typeahead.js'
,
];
];
/**
/**
* @inheritdoc
* @inheritdoc
...
...
framework/yii/gii/assets/main.css
View file @
4cb1a264
...
@@ -201,3 +201,11 @@ body {
...
@@ -201,3 +201,11 @@ body {
.DifferencesInline
.ChangeReplace
del
{
.DifferencesInline
.ChangeReplace
del
{
background
:
#e99
;
background
:
#e99
;
}
}
/* additional styles for typeahead.js-bootstrap.css */
.twitter-typeahead
{
display
:
block
!important
;
}
.twitter-typeahead
.tt-hint
{
padding
:
6px
12px
!important
;
}
framework/yii/gii/assets/typeahead.js
0 → 100644
View file @
4cb1a264
This diff is collapsed.
Click to expand it.
framework/yii/gii/assets/typeahead.js-bootstrap.css
0 → 100644
View file @
4cb1a264
/* always keep this link here when updating this file: https://github.com/jharding/typeahead.js-bootstrap.css */
.twitter-typeahead
.tt-query
,
.twitter-typeahead
.tt-hint
{
margin-bottom
:
0
;
}
.tt-dropdown-menu
{
min-width
:
160px
;
margin-top
:
2px
;
padding
:
5px
0
;
background-color
:
#fff
;
border
:
1px
solid
#ccc
;
border
:
1px
solid
rgba
(
0
,
0
,
0
,
.2
);
*
border-right-width
:
2px
;
*
border-bottom-width
:
2px
;
-webkit-border-radius
:
6px
;
-moz-border-radius
:
6px
;
border-radius
:
6px
;
-webkit-box-shadow
:
0
5px
10px
rgba
(
0
,
0
,
0
,
.2
);
-moz-box-shadow
:
0
5px
10px
rgba
(
0
,
0
,
0
,
.2
);
box-shadow
:
0
5px
10px
rgba
(
0
,
0
,
0
,
.2
);
-webkit-background-clip
:
padding-box
;
-moz-background-clip
:
padding
;
background-clip
:
padding-box
;
}
.tt-suggestion
{
display
:
block
;
padding
:
3px
20px
;
}
.tt-suggestion.tt-is-under-cursor
{
color
:
#fff
;
background-color
:
#0081c2
;
background-image
:
-moz-linear-gradient
(
top
,
#0088cc
,
#0077b3
);
background-image
:
-webkit-gradient
(
linear
,
0
0
,
0
100%
,
from
(
#0088cc
),
to
(
#0077b3
));
background-image
:
-webkit-linear-gradient
(
top
,
#0088cc
,
#0077b3
);
background-image
:
-o-linear-gradient
(
top
,
#0088cc
,
#0077b3
);
background-image
:
linear-gradient
(
to
bottom
,
#0088cc
,
#0077b3
);
background-repeat
:
repeat-x
;
filter
:
progid
:
DXImageTransform
.
Microsoft
.
gradient
(
startColorstr
=
'#ff0088cc'
,
endColorstr
=
'#ff0077b3'
,
GradientType
=
0
)
}
.tt-suggestion.tt-is-under-cursor
a
{
color
:
#fff
;
}
.tt-suggestion
p
{
margin
:
0
;
}
framework/yii/gii/components/ActiveField.php
View file @
4cb1a264
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
yii\gii\components
;
namespace
yii\gii\components
;
use
yii\gii\Generator
;
use
yii\gii\Generator
;
use
yii\helpers\Json
;
/**
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
...
@@ -30,10 +31,18 @@ class ActiveField extends \yii\widgets\ActiveField
...
@@ -30,10 +31,18 @@ class ActiveField extends \yii\widgets\ActiveField
if
(
isset
(
$hints
[
$this
->
attribute
]))
{
if
(
isset
(
$hints
[
$this
->
attribute
]))
{
$this
->
hint
(
$hints
[
$this
->
attribute
]);
$this
->
hint
(
$hints
[
$this
->
attribute
]);
}
}
$autoCompleteData
=
$this
->
model
->
autoCompleteData
();
if
(
isset
(
$autoCompleteData
[
$this
->
attribute
]))
{
if
(
is_callable
(
$autoCompleteData
[
$this
->
attribute
]))
{
$this
->
autoComplete
(
call_user_func
(
$autoCompleteData
[
$this
->
attribute
]));
}
else
{
$this
->
autoComplete
(
$autoCompleteData
[
$this
->
attribute
]);
}
}
}
}
/**
/**
* Makes fi
le
d remember its value between page reloads
* Makes fi
el
d remember its value between page reloads
* @return static the field object itself
* @return static the field object itself
*/
*/
public
function
sticky
()
public
function
sticky
()
...
@@ -41,4 +50,17 @@ class ActiveField extends \yii\widgets\ActiveField
...
@@ -41,4 +50,17 @@ class ActiveField extends \yii\widgets\ActiveField
$this
->
options
[
'class'
]
.=
' sticky'
;
$this
->
options
[
'class'
]
.=
' sticky'
;
return
$this
;
return
$this
;
}
}
/**
* Makes field auto completable
* @param array $data auto complete data (array of callables or scalars)
* @return static the field object itself
*/
public
function
autoComplete
(
$data
)
{
static
$counter
=
0
;
$this
->
inputOptions
[
'class'
]
.=
' typeahead-'
.
(
++
$counter
);
$this
->
form
->
getView
()
->
registerJs
(
"jQuery('.typeahead-
{
$counter
}
').typeahead({local: "
.
Json
::
encode
(
$data
)
.
"});"
);
return
$this
;
}
}
}
framework/yii/gii/generators/model/Generator.php
View file @
4cb1a264
...
@@ -113,6 +113,18 @@ class Generator extends \yii\gii\Generator
...
@@ -113,6 +113,18 @@ class Generator extends \yii\gii\Generator
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
public
function
autoCompleteData
()
{
return
[
'tableName'
=>
function
()
{
return
$this
->
getDbConnection
()
->
getSchema
()
->
getTableNames
();
},
];
}
/**
* @inheritdoc
*/
public
function
requiredTemplates
()
public
function
requiredTemplates
()
{
{
return
[
'model.php'
];
return
[
'model.php'
];
...
...
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