123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /*******************************************************************************
- * IBM Confidential
- *
- * OCO Source Materials
- *
- * A and PM: PD
- *
- * (c) Copyright IBM Corp. 2014
- *
- * The source code for this program is not published or otherwise divested of
- * its trade secrets, irrespective of what has been deposited with the U.S.
- * Copyright Office.
- ******************************************************************************/
- define([
- "dojo/_base/declare",
- "bux/dialogs/FileDialog",
- "dojo/_base/array"
- ],function(declare, FileDialog, array){
- var pdFileDialog = declare("pd/widgets/FileDialog", [FileDialog], {
- //override bux function, so that my folder will be the default.
-
- createSpecialLocationsUiElements: function(topLevelNodes) {
- if ( !topLevelNodes ) {
- // this.model.getChildren() is calling the callback with null when there's an error in the request.
- this.onCancel();
- return;
- }
- this._topLevelNodes = topLevelNodes;
- //Reverse order for now so that the Public Folders appears first.
- for (var i = topLevelNodes.length - 1; i >= 0; i--) {
- this._addSpecialLocationFromTreeView(topLevelNodes[i]);
- }
-
- this.onSpecialLocationsClick("myFolders");
-
- this._locationSelector.dropDown = this._locationSelector.createMenu();
- this._locationSelector.startup();
- },
-
- _addSpecialLocationFromTreeView: function(node) {
- //add supplementId for location buttons.
- this.inherited(arguments);
-
- var sNodeClass = node.i.bux$uiclass;
- var parentNode = this._leftSectionSpecialLocations.domNode.childNodes;
- var currentNode = parentNode[parentNode.length - 1];
-
- if (sNodeClass == "publicFolders") {
- pd.setSupplementId(currentNode, "PUBLISH_DIALOG_PUBLIC_FOLDERS");
- } else if (sNodeClass == "myFolders") {
- pd.setSupplementId(currentNode, "PUBLISH_DIALOG_MY_FOLDERS");
- }
- },
-
- onNewFolderButtonClick: function() {
- //add supplementId for input box and action buttons in newFolder dialog.
- this.inherited(arguments);
-
- if (this.simplePromptDialog) {
- var textField = this.simplePromptDialog.textField;
- pd.setSupplementId(textField.domNode,
- "PUBLISH_DIALOG_NEW_FOLDER_NAME_INPUT");
- pd.setSupplementId(textField.oDlgBtns[0].domNode,
- "PUBLISH_DIALOG_NEW_FOLDER_OK_BUTTON");
- pd.setSupplementId(textField.oDlgBtns[1].domNode,
- "PUBLISH_DIALOG_NEW_FOLDER_CANCEL_BUTTON");
- }
- },
-
- _newFolderErrHandler: function(folderName, error){
- var sMessageDesc = BUXMSG.FDG.IDS_FDG_NEW_FOLDER_ERROR_DESC;
-
- var bFolderExists = (error.message && (error.message.indexOf('CM-REQ-4024')>=0 || error.message.indexOf('BUX-ACM-1507')>=0)) || error.status==409;
-
- if(bFolderExists){
- sMessageDesc = dojo.string.substitute(BUXMSG.FDG.IDS_FDG_NEW_FOLDER_ALREADY_EXISTS_ERROR, [bux.Bidi.enforceTextDir(folderName)]);
- }else{
- this.simplePromptDialog.destroyRecursive();
- delete this.simplePromptDialog;
- }
- return pd.messageBox(pd.statics.MB_ERROR, BUXMSG.FDG.IDS_FDG_NEW_FOLDER_ERROR,
- sMessageDesc, error.message);
- }
- });
-
- var SaveDialog = declare("pd/widgets/SaveDialog", [bux.dialogs.SaveDialog, pdFileDialog], {
- constructor: function(args){
- this.inherited(arguments);
- this.pdDefaultName = args.pdDefaultName;
-
- var ALLOWED_OPERATION = ["refresh", "createNewFolder"];
- dojo.mixin(bux.IWidgetUtils, {
- //override bux object so that "refresh" and "createNewFolder" button showed in the publish dialog.
- getIWidgetById: function(){
- return {
- iScope:{
- isOperationAllowed: function(operation) {
- return array.indexOf(ALLOWED_OPERATION, operation) != -1;
- }
- }
- };
- }
- });
- },
-
- checkAndEnableMainAction: function(_item) {
- var sSaveAsName = this._objectNameField.get('value');
- if(bux.Bidi.getTextDir()) {
- if(!_item && dojo.isIE) {
- this._objectNameField.focusNode.style.overflowX = "visible";
- }
- if(!_item || !_item.keyCode || bux.Bidi.doesKeyImpactsDir(_item.keyCode)) {
- bux.Bidi.setInputDirByValue(this._objectNameField.domNode, sSaveAsName);
- }
- }
- var bIsValid = (
- ((this.oCurrentPath && (this.oCurrentPath.bux$uiclass == "myFolders" ||
- this.oCurrentPath.bux$uiclass == "publicFolders")) ||
- (_item && bux.CMHelper.hasPermissions(_item.cm$permissions, "WT&") &&
- this._getCurrentNodeFromView())) &&
- (sSaveAsName && dojo.trim(sSaveAsName).length >0 ? true : false));
- if(this._aButtonObjects && this._aButtonObjects[0]){
- this._aButtonObjects[0].set( 'disabled', !bIsValid );
- }
- this._bCanExecuteAction = bIsValid;
- return bIsValid;
- },
-
- onMainAction: function() {
- if (this.saveAsHandler) {
- var saveAsName = this._objectNameField.get('value');
- // check for presence of both ' and " - this is not supported by CM
- if (-1 != saveAsName.indexOf("'") && -1 != saveAsName.indexOf('"')) {
- bux.messageBox(bux.MB_ERROR,
- BUXMSG.CDG.IDS_CDG_SAVE_CHANGE_NAME_TITLE,
- dojo.string.substitute(BUXMSG.EDG.IDS_EDG_ERROR_MIXED_USE_QUOTES, [bux.Bidi.enforceTextDir(saveAsName)]));
- return;
- }
- var containerNodeFromView = this._getCurrentNodeFromView();
- var containerNode = null;
- if (containerNodeFromView) {
- var containerNodeItem = containerNodeFromView.getItem();
- if (containerNodeItem && containerNodeItem.cm$objectClass != "folder" && containerNodeItem.cm$objectClass != "package") {
- containerNode = containerNodeFromView.getParent();
- } else {
- containerNode = containerNodeFromView;
- }
- }
- var fHandler = this.saveAsHandler;
- var oLink = null;
- var fCallback = this.callBackFunction;
- if (saveAsName && containerNode &&
- this.getCurrentTreeView().getNodeLink(containerNode, "up")) {
- oLink = this.getCurrentTreeView().getNodeLink(containerNode, "self");
- } else if ((this.oCurrentPath.bux$uiclass == "myFolders" ||
- this.oCurrentPath.bux$uiclass == "publicFolders") && saveAsName) {
- var _myFolderPath = dojox.json.query("?rel='self'",this.oCurrentPath.link);
- oLink = _myFolderPath[0].href;
- }
- var oContainerItem = {"i" : this._getCurrentSelectedContainer()};//Extra parent container item
- if (oLink) {
- // Refresh the Tree's data for the next time the dialog is opened.
- if (this.treeView) {
- this.treeView.clearTree();
- }
- if (this.listView) {
- this.listView.clearTree();
- }
- this.hide();
- setTimeout(function() {fHandler(saveAsName, oLink, fCallback, oContainerItem)}, 10);
- } else {
- window.alert(BUXMSG.FDG.IDS_FDG_INVALID_ARGUMENTS);
- }
- }
- },
-
- startup: function() {
- this.inherited(arguments);
- this._objectNameField.set("value", this.pdDefaultName);
-
- //add supplementId for publish dialog
- pd.setSupplementId(this.domNode, "PUBLISH_DIALOG");
-
- //add supplementId for action buttons
- pd.setSupplementId(this._aButtonObjects[0].domNode,
- "PUBLISH_DIALOG_PUBLISH_BUTTON");
- pd.setSupplementId(this._aButtonObjects[1].domNode,
- "PUBLISH_DIALOG_CANCEL_BUTTON");
-
- //add supplementId for newFolder button
- pd.setSupplementId(this.newFolderButton.domNode,
- "PUBLISH_DIALOG_NEW_FOLDER");
- //add supplementId for name input box
- pd.setSupplementId(this._objectNameField.domNode,
- "PUBLISH_DIALOG_NAME_INPUT");
- }
- });
-
- return SaveDialog;
- });
|