Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add identifier mask for descriptions, refs #11162
This PR implements a similar feature to our existing accession mask settings, except for archival descriptions' identifiers instead. Feature details: - New admin->settings fields for identifier mask, identifier counter, and identifier mask enable / disable. - If identifier mask is enabled, when creating new descriptions the identifier will automatically fill in an auto-generated identifier in the form for the user, based on the mask & counter. - There will be a button underneath the identifier text box when editing that will use an XHR to manually generate an identifier from an end point and fill the box in. - In the identifier mask (like accession mask), %<letter> indicates the identifier generation should interpret this with strftime. #i should be interpreted as the place to insert the current counter value. - If the user edits the identifier either during the creation process if identifier mask is enabled, or after the user clicks generate identifier manually, the counter will not be incremented.
- Loading branch information
Mike Gale
committed
May 18, 2017
1 parent
18f9a78
commit b1e82cd
Showing
21 changed files
with
322 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apps/qubit/modules/informationobject/actions/generateIdentifierAction.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Access to Memory (AtoM) software. | ||
* | ||
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Access to Memory (AtoM) is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
class InformationObjectGenerateIdentifierAction extends sfAction | ||
{ | ||
public function execute($request) | ||
{ | ||
$identifier = QubitInformationObject::generateIdentiferFromMask(); | ||
$this->response->setHttpHeader('Content-Type', 'application/json; charset=utf-8'); | ||
|
||
return $this->renderText(json_encode(array('identifier' => $identifier))); | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
apps/qubit/modules/informationobject/templates/_alternativeIdentifiers.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/qubit/modules/informationobject/templates/_identifierOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="section"> | ||
<?php if (!isset($hideAltIdButton)): // Some templates don't have alt id support yet ?> | ||
<a href="#" class="identifier-action" id="alternative-identifiers"> | ||
<?php echo __('Add alternative identifier(s)') ?> | ||
</a> | ||
<?php endif; ?> | ||
|
||
<a href="#" class="identifier-action" id="generate-identifier" | ||
data-generate-identifier-url="<?php echo url_for(array('module' => 'informationobject', 'action' => 'generateIdentifier')) ?>"> | ||
<?php echo __('Generate identifier') ?> | ||
</a> | ||
</div> | ||
|
||
<input name="usingMask" id="using-identifier-mask" type="hidden" value="<?php echo $mask ?>"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
(function ($) { | ||
|
||
'use strict'; | ||
|
||
var GenerateIdentifier = function () | ||
{ | ||
this.$generateIdentifierBtn = $('#generate-identifier'); | ||
this.$identifier = $('#identifier'); | ||
this.$maskEnabled = $('#using-identifier-mask'); | ||
this.init(); | ||
}; | ||
|
||
GenerateIdentifier.prototype = { | ||
|
||
constructor: GenerateIdentifier, | ||
|
||
init: function() | ||
{ | ||
this.$generateIdentifierBtn.on('click', $.proxy(this.genIdentifier, this)); | ||
this.$identifier.on('input', $.proxy(this.identifierChanged, this)); | ||
}, | ||
|
||
genIdentifier: function(event) | ||
{ | ||
var identifier = this.$identifier; | ||
var maskEnabled = this.$maskEnabled; | ||
event.preventDefault(); // Prevent page from jumping to top when clicking href="#" | ||
|
||
// Return deferred object | ||
return $.ajax({ | ||
url: this.$generateIdentifierBtn.data('generate-identifier-url'), | ||
type: 'GET', | ||
success: function (data) | ||
{ | ||
identifier.val(data['identifier']); | ||
// Freshly generated identifier, using mask! | ||
maskEnabled.attr('value', '1'); | ||
} | ||
}); | ||
}, | ||
|
||
// If user changes identifier manually, we're no longer using an auto-generated | ||
// identifier from the mask, so do not increment counter. Using-mask will signal | ||
// to the action whether or not to increment the counter. | ||
identifierChanged: function(event) | ||
{ | ||
this.$maskEnabled.attr('value', '0'); | ||
} | ||
}; | ||
|
||
$(function () | ||
{ | ||
new GenerateIdentifier(); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.