Merge pull request #262 from halkyon/security_import

ENHANCEMENT Adding missing MemberImportForm to SecurityAdmin, and styling fixes.
This commit is contained in:
Sam Minnée 2012-03-23 17:39:46 -07:00
commit 1b24437fde
7 changed files with 65 additions and 26 deletions

View File

@ -49,13 +49,16 @@ class GroupImportForm extends Form {
}
if(!$actions) $actions = new FieldList(
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
$importAction = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'))
);
$importAction->addExtraClass('ss-ui-button');
if(!$validator) $validator = new RequiredFields('CsvFile');
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}

View File

@ -17,7 +17,7 @@ class MemberImportForm extends Form {
if(!$fields) {
$helpHtml = _t(
'MemberImportForm.Help1',
'<p>Import members in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
'<p>Import users in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
);
$helpHtml .= _t(
'MemberImportForm.Help2',
@ -25,7 +25,7 @@ class MemberImportForm extends Form {
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
<li>Existing members are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li>
<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li>
<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, multiple groups can be separated by comma. Existing group memberships are not cleared.</li>
</ul>
</div>');
@ -48,16 +48,19 @@ class MemberImportForm extends Form {
}
if(!$actions) $actions = new FieldList(
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
$importAction = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'))
);
$importAction->addExtraClass('ss-ui-button');
if(!$validator) $validator = new RequiredFields('CsvFile');
parent::__construct($controller, $name, $fields, $actions, $validator);
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/MemberImportForm.js');
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}

View File

@ -74,10 +74,26 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
'Caution: Removing members from this list will remove them from all groups and the database'
)
)
),
new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3),
new LiteralField(
'MemberImportFormIframe',
sprintf(
'<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" border="0"></iframe>',
$this->Link('memberimport')
)
)
),
new Tab('Groups', singleton('Group')->plural_name(),
$groupList
$groupList,
new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3),
new LiteralField(
'GroupImportFormIframe',
sprintf(
'<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" border="0"></iframe>',
$this->Link('groupimport')
)
)
)
),
// necessary for tree node selection in LeftAndMain.EditForm.js
@ -104,17 +120,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$rolesTab->push($rolesField);
}
$fields->findOrMakeTab('Root.Import', _t('SecurityAdmin.TABIMPORT', 'Import'));
$fields->addFieldToTab('Root.Import',
new LiteralField(
'GroupImportFormIframe',
sprintf(
'<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>',
$this->Link('groupimport')
)
)
);
$actions = new FieldList();
$form = new Form(
@ -275,4 +280,4 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
static function clear_hidden_permissions(){
self::$hidden_permissions = array();
}
}
}

View File

@ -109,6 +109,7 @@ body, html { font-size: 12px; line-height: 16px; font-family: Arial, sans-serif;
.cms h4 { font-size: 14px; }
.cms h5 { font-size: 12px; }
.cms p { line-height: 16px; margin-bottom: 16px; }
.cms em { font-style: italic; }
.cms code { font-family: 'Bitstream Vera Sans Mono','Courier', monospace; }
/** This file defines CMS-specific customizations to the jQuery UI theme. Every rule in this file should be wrapped in the '.cms' selector (to make it more specific), and contain ONLY overwritten jQuery UI rules (with 'ui-' prefix). This file should be fairly short, as we're using our own custom jQuery UI theme already. TODO Add theme reference Use _style.scss to add more generic style information, and read the jQuery UI theming API: http://jqueryui.com/docs/Theming/API */
@ -508,6 +509,12 @@ form.small .cms-file-info-data .field .middleColumn { margin-left: 120px; }
.members_grid p button#action_export span.btn-icon-download-csv { height: 17px; }
.members_grid p button#action_export span.ui-button-text { padding-left: 26px; }
/** Import forms */
form.import-form ul { list-style: disc; }
form.import-form ul li { margin-left: 20px; }
form.import-form p { margin-bottom: 5px; }
form.import-form label.left { width: 250px; }
/** This file defines the jstree base styling (see http://jstree.com), as well as any customizations (see bottom of file). The styles are usually added through jstree.js on DOM load, but we need it earlier in order to correctly display the uninitialized tree. */
.cms .jstree ul, .TreeDropdownField .treedropdownfield-panel .jstree ul { display: block; margin: 0; padding: 0; background: none; list-style-type: none; }
.cms .jstree li, .TreeDropdownField .treedropdownfield-panel .jstree li { display: block; margin: 0; padding: 0; list-style-type: none; display: block; min-height: 18px; line-height: 18px; white-space: nowrap; margin-left: 18px; min-width: 18px; }

View File

@ -1373,4 +1373,23 @@ form.small {
padding-left:26px; //to accomodate wider export icon
}
}
}
}
/**
* Import forms
*/
form.import-form {
ul {
list-style: disc;
li {
margin-left: 20px;
}
}
p {
margin-bottom: 5px;
}
label.left {
width: 250px;
}
}

View File

@ -38,7 +38,9 @@ body, html {
line-height: $grid-y * 2;
margin-bottom: $grid-y * 2;
}
em {
font-style: italic;
}
code {
font-family: 'Bitstream Vera Sans Mono','Courier', monospace;
}

View File

@ -559,12 +559,12 @@ $lang['en_US']['MemberDatetimeOptionsetField']['TWODIGITYEAR'] = array(
40,
'Help text describing what "YY" means in ISO date formatting'
);
$lang['en_US']['MemberImportForm']['Help1'] = '<p>Import members in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>';
$lang['en_US']['MemberImportForm']['Help1'] = '<p>Import users in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>';
$lang['en_US']['MemberImportForm']['Help2'] = '<div class="advanced">
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
<li>Existing members are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li>
<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li>
<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, multiple groups can be separated by comma. Existing group memberships are not cleared.</li>
</ul>
</div>';
@ -735,7 +735,7 @@ $lang['en_US']['SecurityAdmin']['SGROUPS'] = 'Security Groups';
$lang['en_US']['SecurityAdmin']['TABIMPORT'] = 'Import';
$lang['en_US']['SecurityAdmin']['TABROLES'] = 'Roles';
$lang['en_US']['SecurityAdmin']['VIEWUSER'] = 'View User';
$lang['en_US']['SecurityAdmin_MemberImportForm']['BtnImport'] = 'Import';
$lang['en_US']['SecurityAdmin_MemberImportForm']['BtnImport'] = 'Import from CSV';
$lang['en_US']['SecurityAdmin_MemberImportForm']['FileFieldLabel'] = 'CSV File <small>(Allowed extensions: *.csv)</small>';
$lang['en_US']['SimpleImageField']['NOUPLOAD'] = 'No Image Uploaded';
$lang['en_US']['SiteTree']['TABMAIN'] = 'Main';