/*
 *  Copyright 2013 Anyware Services
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/**
 * This class controls ribbon buttons that will be responsible for a workflow action on an old version of a content.
 * The button will be enabled only if the workflow action is available for current selection.
 * @private
 */
Ext.define('Ametys.plugins.cms.content.controller.OldContentController', {
    extend: 'Ametys.plugins.cms.content.controller.SmartContentController',
    
    /**
     * @protected
     * Compares two targets and returns true if the two targets are equals.
     * This implementation compares content versions in addition to IDs.
     * @return true if the two targets are the same.
     */
    areSameTargets: function (target1, target2)
    {
        // Standard SmartContentController checks.
        var same = this.callParent(arguments);
        
        if (same)
        {
            // Check that the content versions are the same as well.
            if (target1.getParameters().version && target2.getParameters().version)
            {
                return target1.getParameters().version == target2.getParameters().version;
            }
        }
        
        return false;
    }
});