Ignore:
Timestamp:
07/27/11 09:45:44 (13 years ago)
Author:
twagoo
Message:

GUI: implemented ComponentUsageService?, which calls the component/usage/ (see @1462-@1465) service to check whether the specified component is in use.
It is called when updating private components. Currently, the service response is not being processed so the event will always tell the component is in use.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorAS.as

    r1086 r1473  
    99import clarin.cmdi.componentregistry.services.ComponentInfoService;
    1010import clarin.cmdi.componentregistry.services.ComponentListService;
     11import clarin.cmdi.componentregistry.services.ComponentUsageCheckEvent;
     12import clarin.cmdi.componentregistry.services.ComponentUsageService;
    1113import clarin.cmdi.componentregistry.services.Config;
    1214import clarin.cmdi.componentregistry.services.ProfileInfoService;
     
    8890
    8991private function saveSpec(inUserSpace:Boolean, uploadAction:int):void {
    90 //      Alert.show(xmlEditor.cmdSpec.toXml());
     92        //      Alert.show(xmlEditor.cmdSpec.toXml());
    9193        if (xmlEditor.validate()) {
    9294                var item:ItemDescription = new ItemDescription();
     
    100102                        item.id = xmlEditor.cmdSpec.headerId;
    101103                }
    102                 uploadService.upload(uploadAction, item, xmlEditor.cmdSpec.toXml());
     104               
     105                // Private components that are in updated require usage check call. If in use, the user can choose whether or not to save the changes .
     106                if(inUserSpace && uploadAction == UploadService.UPDATE && !item.isProfile){
     107                        checkUsage(item);
     108                }else{
     109                        doUpload(uploadAction,item);
     110                }
    103111        } else {
    104112                errorMessageField.text = "Validation errors: red colored fields are invalid.";
    105113        }
     114}
     115
     116/**
     117 * Calls usage check for the specified component. If in use, asks user whether to proceed; if positive, initiates update.
     118 */
     119private function checkUsage(item:ItemDescription, uploadAction:int = UploadService.UPDATE):void{
     120        var componentUsageService:ComponentUsageService = new ComponentUsageService(item);
     121        componentUsageService.addEventListener(ComponentUsageCheckEvent.COMPONENT_IN_USE,
     122                function (event:ComponentUsageCheckEvent):void{
     123                        if(event.isComponentInUse){
     124                                Alert.show("Component is used by other components and/or profiles. Changes in this component will affect these. Do you want to proceed?","Component is used", Alert.YES|Alert.NO,null,
     125                                        function (eventObj:CloseEvent):void{
     126                                                if(eventObj.detail == Alert.YES){
     127                                                        doUpload(uploadAction, item);
     128                                                }
     129                                        });
     130                        } else {
     131                                doUpload(uploadAction,item);
     132                        }
     133                });
     134        componentUsageService.checkUsage();
     135}
     136
     137private function doUpload(uploadAction:int, item:ItemDescription):void{
     138        uploadService.upload(uploadAction, item, xmlEditor.cmdSpec.toXml());
    106139}
    107140
Note: See TracChangeset for help on using the changeset viewer.