Skip to content

Commit a4ab929

Browse files
ShaileshInfyommitulgolakiya
authored andcommitted
feat(views): InfyOmLabs#734 support to exclude filed from show page (InfyOmLabs#737)
1 parent 69c2eb1 commit a4ab929

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

samples/fields_sample.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"fillable": false,
99
"primary": true,
1010
"inForm": false,
11-
"inIndex": false
11+
"inIndex": false,
12+
"inView": false
1213
},
1314
{
1415
"name": "title",
@@ -34,15 +35,17 @@
3435
"htmlType": "password",
3536
"searchable": false,
3637
"inForm": false,
37-
"inIndex": false
38+
"inIndex": false,
39+
"inView": false
3840
},
3941
{
4042
"name": "token",
4143
"dbType": "string",
4244
"htmlType": "hidden",
4345
"searchable": false,
4446
"inForm": false,
45-
"inIndex": false
47+
"inIndex": false,
48+
"inView": false
4649
},
4750
{
4851
"name": "email",

src/Commands/BaseCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ private function saveSchemaFile()
205205
'primary' => $field->isPrimary,
206206
'inForm' => $field->inForm,
207207
'inIndex' => $field->inIndex,
208+
'inView' => $field->inView,
208209
];
209210
}
210211

src/Common/GeneratorField.php

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GeneratorField
2828
public $isPrimary = false;
2929
public $inForm = true;
3030
public $inIndex = true;
31+
public $inView = true;
3132
public $isNotNull = false;
3233

3334
public function parseDBType($dbInput)
@@ -70,6 +71,7 @@ public function parseOptions($options)
7071
$this->isFillable = false;
7172
$this->inForm = false;
7273
$this->inIndex = false;
74+
$this->inView = false;
7375
}
7476
if (in_array('f', $optionsArr)) {
7577
$this->isFillable = false;
@@ -80,6 +82,9 @@ public function parseOptions($options)
8082
if (in_array('ii', $optionsArr)) {
8183
$this->inIndex = false;
8284
}
85+
if (in_array('iv', $optionsArr)) {
86+
$this->inView = false;
87+
}
8388
}
8489

8590
private function prepareMigrationText()
@@ -136,6 +141,7 @@ public static function parseFieldFromFile($fieldInput)
136141
$field->isPrimary = isset($fieldInput['primary']) ? $fieldInput['primary'] : false;
137142
$field->inForm = isset($fieldInput['inForm']) ? $fieldInput['inForm'] : true;
138143
$field->inIndex = isset($fieldInput['inIndex']) ? $fieldInput['inIndex'] : true;
144+
$field->inView = isset($fieldInput['inView']) ? $fieldInput['inView'] : true;
139145

140146
return $field;
141147
}

src/Generators/Scaffold/ViewGenerator.php

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ private function generateShowFields()
242242
$fieldsStr = '';
243243

244244
foreach ($this->commandData->fields as $field) {
245+
if (!$field->inView) {
246+
continue;
247+
}
245248
$singleFieldStr = str_replace('$FIELD_NAME_TITLE$', Str::title(str_replace('_', ' ', $field->name)),
246249
$fieldTemplate);
247250
$singleFieldStr = str_replace('$FIELD_NAME$', $field->name, $singleFieldStr);

src/Utils/TableFieldsGenerator.php

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public function prepareFieldsFromTable()
149149
$field->isFillable = false;
150150
$field->inForm = false;
151151
$field->inIndex = false;
152+
$field->inView = false;
152153
}
153154
$field->isNotNull = (bool) $column->getNotNull();
154155
$field->description = $column->getComment(); // get comments from table
@@ -233,6 +234,7 @@ private function checkForPrimary(GeneratorField $field)
233234
$field->isSearchable = false;
234235
$field->inIndex = false;
235236
$field->inForm = false;
237+
$field->inView = false;
236238
}
237239

238240
return $field;

tests/Utils/GeneratorFieldsInputUtilTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function testProcessFieldInput()
4242
$this->assertFalse($res->isPrimary);
4343
$this->assertTrue($res->inForm);
4444
$this->assertTrue($res->inIndex);
45+
$this->assertTrue($res->inView);
4546

4647
// name string,20 textarea
4748
$input = 'name string,20 textarea';
@@ -95,6 +96,7 @@ public function testProcessFieldInput()
9596
$this->assertFalse($res->isPrimary);
9697
$this->assertFalse($res->inForm);
9798
$this->assertTrue($res->inIndex);
99+
$this->assertTrue($res->inView);
98100
}
99101

100102
public function testPrepareKeyValueArrayStr()

0 commit comments

Comments
 (0)