[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
index fe95b03..a7c95f6 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
@@ -39,7 +39,9 @@
aggregationFunction: entitlementPool.aggregationFunction,
operationalScope: entitlementPool.operationalScope,
time: entitlementPool.time,
- manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber
+ manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber,
+ startDate: entitlementPool.startDate,
+ expiryDate: entitlementPool.expiryDate
});
}
@@ -55,7 +57,9 @@
aggregationFunction: entitlementPool.aggregationFunction,
operationalScope: entitlementPool.operationalScope,
time: entitlementPool.time,
- manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber
+ manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber,
+ startDate: entitlementPool.startDate,
+ expiryDate: entitlementPool.expiryDate
});
}
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
index ba0b238..761614d 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
@@ -113,3 +113,5 @@
};
export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL';
+
+export const EP_TIME_FORMAT = 'MM/DD/YYYY';
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
index db1a3a9..bc95497 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
@@ -14,10 +14,20 @@
* permissions and limitations under the License.
*/
import {actionTypes, defaultState, SP_ENTITLEMENT_POOL_FORM} from './EntitlementPoolsConstants.js';
+import moment from 'moment';
+import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js';
export default (state = {}, action) => {
switch (action.type) {
case actionTypes.entitlementPoolsEditor.OPEN:
+ let entitlementPoolData = {...action.entitlementPool};
+ let {startDate, expiryDate} = entitlementPoolData;
+ if (startDate) {
+ entitlementPoolData.startDate = moment(startDate, DATE_FORMAT).format(DATE_FORMAT);
+ }
+ if (expiryDate) {
+ entitlementPoolData.expiryDate = moment(expiryDate, DATE_FORMAT).format(DATE_FORMAT);
+ }
return {
...state,
formReady: null,
@@ -72,9 +82,19 @@
isValid: true,
errorText: '',
validations: [{type: 'required', data: true}]
+ },
+ 'startDate': {
+ isValid: true,
+ errorText: '',
+ validations: []
+ },
+ 'expiryDate': {
+ isValid: true,
+ errorText: '',
+ validations: []
}
},
- data: action.entitlementPool ? {...action.entitlementPool} : defaultState.ENTITLEMENT_POOLS_EDITOR_DATA
+ data: action.entitlementPool ? entitlementPoolData : defaultState.ENTITLEMENT_POOLS_EDITOR_DATA
};
case actionTypes.entitlementPoolsEditor.DATA_CHANGED:
return {
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx
index d484437..e4b52fc 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx
@@ -23,7 +23,7 @@
import Form from 'nfvo-components/input/validation/Form.jsx';
import GridSection from 'nfvo-components/grid/GridSection.jsx';
import GridItem from 'nfvo-components/grid/GridItem.jsx';
-import {optionsInputValues as EntitlementPoolsOptionsInputValues, thresholdUnitType, SP_ENTITLEMENT_POOL_FORM} from './EntitlementPoolsConstants.js';
+import {optionsInputValues as EntitlementPoolsOptionsInputValues, thresholdUnitType, SP_ENTITLEMENT_POOL_FORM, EP_TIME_FORMAT} from './EntitlementPoolsConstants.js';
import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx';
const EntitlementPoolPropType = React.PropTypes.shape({
@@ -50,10 +50,11 @@
})
});
-const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, validateChoiceWithOther, validateTimeOtherValue, thresholdValueValidation}) => {
+const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, validateChoiceWithOther, validateTimeOtherValue,
+ thresholdValueValidation, validateStartDate}) => {
let {
name, description, manufacturerReferenceNumber, operationalScope , aggregationFunction, thresholdUnits, thresholdValue,
- increments, time, entitlementMetric} = data;
+ increments, time, entitlementMetric, startDate, expiryDate} = data;
return (
<GridSection>
@@ -175,6 +176,8 @@
onChange={manufacturerReferenceNumber => onDataChanged({manufacturerReferenceNumber}, SP_ENTITLEMENT_POOL_FORM)}
label={i18n('Manufacturer Reference Number')}
value={manufacturerReferenceNumber}
+ isValid={genericFieldInfo.manufacturerReferenceNumber.isValid}
+ errorText={genericFieldInfo.manufacturerReferenceNumber.errorText}
isRequired={true}
data-test-id='create-ep-reference-number'
type='text'/>
@@ -206,6 +209,40 @@
data-test-id='create-ep-increments'
type='text'/>
</GridItem>
+ <GridItem colSpan={2} />
+ <GridItem colSpan={2}>
+ <Input
+ type='date'
+ label={i18n('Start Date')}
+ value={startDate}
+ dateFormat={EP_TIME_FORMAT}
+ startDate={startDate}
+ endDate={expiryDate}
+ onChange={startDate => onDataChanged(
+ {startDate: startDate ? startDate.format(EP_TIME_FORMAT) : ''},
+ SP_ENTITLEMENT_POOL_FORM,
+ {startDate: validateStartDate}
+ )}
+ isValid={genericFieldInfo.startDate.isValid}
+ errorText={genericFieldInfo.startDate.errorText}
+ selectsStart/>
+ </GridItem>
+ <GridItem colSpan={2}>
+ <Input
+ type='date'
+ label={i18n('Expiry Date')}
+ value={expiryDate}
+ dateFormat={EP_TIME_FORMAT}
+ startDate={startDate}
+ endDate={expiryDate}
+ onChange={expiryDate => {
+ onDataChanged({expiryDate: expiryDate ? expiryDate.format(EP_TIME_FORMAT) : ''}, SP_ENTITLEMENT_POOL_FORM);
+ onDataChanged({startDate}, SP_ENTITLEMENT_POOL_FORM, {startDate: validateStartDate});
+ }}
+ isValid={genericFieldInfo.expiryDate.isValid}
+ errorText={genericFieldInfo.expiryDate.errorText}
+ selectsEnd/>
+ </GridItem>
</GridSection>
);
};
@@ -251,6 +288,7 @@
validateName={(value)=> this.validateName(value)}
validateTimeOtherValue ={(value)=> this.validateTimeOtherValue(value)}
validateChoiceWithOther={(value)=> this.validateChoiceWithOther(value)}
+ validateStartDate={(value, state)=> this.validateStartDate(value, state)}
thresholdValueValidation={(value, state)=> this.thresholdValueValidation(value, state)}/>
</Form>
}
@@ -271,6 +309,15 @@
{isValid: false, errorText: i18n('Entitlement pool by the name \'' + value + '\' already exists. Entitlement pool name must be unique')};
}
+ validateStartDate(value, state) {
+ if (state.data.expiryDate) {
+ if (!value) {
+ return {isValid: false, errorText: i18n('Start date has to be specified if expiry date is specified')};
+ }
+ }
+ return {isValid: true, errorText: ''};
+ }
+
validateTimeOtherValue(value) {
return Validator.validate('time', value.other, [{type: 'required', data: true}, {type: 'numeric', data: true}]);
}
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx
index 07a6f21..55fd11b 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx
@@ -45,14 +45,14 @@
};
render() {
- let {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props;
+ let {licenseModelId, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props;
let {onAddEntitlementPoolClick} = this.props;
const {localFilter} = this.state;
return (
<div className='entitlement-pools-list-editor'>
<ListEditorView
- title={i18n('Entitlement Pools', {vendorName})}
+ title={i18n('Entitlement Pools')}
plusButtonTitle={i18n('Add Entitlement Pool')}
onAdd={onAddEntitlementPoolClick}
filterValue={localFilter}
@@ -132,7 +132,7 @@
export function generateConfirmationMsg(entitlementPoolToDelete) {
let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : '';
- let msg = i18n('Are you sure you want to delete "{poolName}"?', {poolName});
+ let msg = i18n(`Are you sure you want to delete "${poolName}"?`);
let subMsg = entitlementPoolToDelete
&& entitlementPoolToDelete.referencingFeatureGroups
&& entitlementPoolToDelete.referencingFeatureGroups.length > 0 ?