Skip to content

Commit

Permalink
Render Enrollment Attributes edit/add/view in a modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis authored and arlen committed Sep 24, 2024
1 parent 23bac8d commit 63c5968
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
class EnrollmentAttributesTable extends Table {
use \App\Lib\Traits\AutoViewVarsTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
$indexColumns = [
'label' => [
'type' => 'link',
'sortable' => true
'sortable' => true,
'class' => 'cm-modal-link nospin', // launch this in a modal
'dataAttrs' => [
['data-cm-modal-title', __d('operation', 'EnrollmentAttributes', 1)]
]
],
'attribute' => [
// XXX we probably want to render something more like v4 does
Expand Down
48 changes: 48 additions & 0 deletions app/src/Lib/Traits/LayoutTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* COmanage Registry Layout Trait
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

namespace App\Lib\Traits;

trait LayoutTrait
{
/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
'add',
'view',
'edit' => 'iframe',
default => 'default'
};
}
}
13 changes: 1 addition & 12 deletions app/src/Model/Table/AdHocAttributesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,14 @@ class AdHocAttributesTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}

/**
* Perform Cake Model initialization.
Expand Down
15 changes: 2 additions & 13 deletions app/src/Model/Table/AddressesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ class AddressesTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\TypeTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\SearchFilterTrait;

// Default "out of the box" types for this model. Entries here should be
// given a default localization in app/resources/locales/*/defaultType.po
Expand All @@ -58,18 +59,6 @@ class AddressesTable extends Table {
'postal'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}

/**
* Perform Cake Model initialization.
Expand Down
15 changes: 2 additions & 13 deletions app/src/Model/Table/EmailAddressesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class EmailAddressesTable extends Table {
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LabeledLogTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand All @@ -66,19 +67,7 @@ class EmailAddressesTable extends Table {
'recovery'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}


/**
* Perform Cake Model initialization.
*
Expand Down
13 changes: 1 addition & 12 deletions app/src/Model/Table/ExtIdentitySourceRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,14 @@ class ExtIdentitySourceRecordsTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\LabeledLogTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}

/**
* Perform Cake Model initialization.
*
Expand Down
16 changes: 2 additions & 14 deletions app/src/Model/Table/GroupMembersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,14 @@ class GroupMembersTable extends Table {
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LabeledLogTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\SearchFilterTrait;

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
'add','edit','view' => 'iframe',
default => 'default'
};
}

/**
* Perform Cake Model initialization.
Expand Down
15 changes: 2 additions & 13 deletions app/src/Model/Table/IdentifiersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class IdentifiersTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand Down Expand Up @@ -73,19 +74,7 @@ class IdentifiersTable extends Table {
'uid'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}


/**
* Perform Cake Model initialization.
*
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/NamesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class NamesTable extends Table {
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LabeledLogTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand All @@ -53,7 +54,6 @@ class NamesTable extends Table {
use \App\Lib\Traits\TypeTrait;
use \App\Lib\Traits\ValidationTrait;


// Default "out of the box" types for this model. Entries here should be
// given a default localization in app/resources/locales/*/defaultType.po
protected $defaultTypes = [
Expand Down
15 changes: 2 additions & 13 deletions app/src/Model/Table/PronounsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PronounsTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand All @@ -54,19 +55,7 @@ class PronounsTable extends Table {
'default'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}


/**
* Perform Cake Model initialization.
*
Expand Down
17 changes: 3 additions & 14 deletions app/src/Model/Table/TelephoneNumbersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TelephoneNumbersTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand All @@ -46,7 +47,7 @@ class TelephoneNumbersTable extends Table {
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\TypeTrait;
use \App\Lib\Traits\ValidationTrait;

// Default "out of the box" types for this model. Entries here should be
// given a default localization in app/resources/locales/*/defaultType.po
protected $defaultTypes = [
Expand All @@ -58,19 +59,7 @@ class TelephoneNumbersTable extends Table {
'office'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}


/**
* Perform Cake Model initialization.
*
Expand Down
15 changes: 2 additions & 13 deletions app/src/Model/Table/UrlsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class UrlsTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\HistoryTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\ProvisionableTrait;
Expand All @@ -54,19 +55,7 @@ class UrlsTable extends Table {
'personal'
]
];

/**
* Provide the default layout
*
* @since COmanage Registry v5.0.0
* @return string Type of redirect
*/
public function getLayout(string $action = ''): string {
return match($action) {
default => 'iframe'
};
}


/**
* Perform Cake Model initialization.
*
Expand Down
13 changes: 13 additions & 0 deletions app/src/View/Helper/CommonHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,25 @@

namespace App\View\Helper;

use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
use Cake\View\Helper;

class CommonHelper extends Helper
{
/**
* Get reference to Model Table
*
* @param string $modelsName
*
* @return Table
*/
public function getModelTableReference(string $modelsName): Table
{
return TableRegistry::getTableLocator()->get($modelsName);
}

/**
* Select count(*)
*
Expand Down
Loading

0 comments on commit 63c5968

Please sign in to comment.